Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2010
    Posts
    199
    Thanks
    78
    Thanked 5 Times in 5 Posts

    [SOLVED] - htaccess mod_rewrite file

    Hi guys Im trying to rewrite my news.php to news/ as if its a directory.
    But the problem is when I rewrite it like that and someone removes the /
    The page will display a 404 message now this seems right sins I did rewrite it to news/ but how would I be able to still display it when someone removes that /

    This is my htaccess code so far.
    Thanks for the help.

    Code:
    <IfModule mod_rewrite.c>
    	RewriteEngine on
    	RewriteRule ^news/$ news.php [L]
    </IfModule>
    Last edited by conware; 03-23-2011 at 06:31 PM. Reason: Thread has been solved!

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Add a ? after the /. That makes it optional.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    conware (03-23-2011)

  • #3
    Regular Coder
    Join Date
    Mar 2010
    Posts
    199
    Thanks
    78
    Thanked 5 Times in 5 Posts
    Thanks for the tip Fou-Lu. works like a charm


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •