simple mod_rewrite question??
I wanted to redirect urls such as www.domain.com/folder
to a file:
I have managed to do this with mod_rewrite, however I dont know how to deal with the case if there is no trailing slash..
Here is what I used
RewriteRule ^([a-z]*)/$ display.php?category=$1
I just need a way to direct them to the same place whether they use a trailing slash or not.....
Any help is greatly appreciated....
RewriteRule ^([a-z]*)/?$ display.php?category=$1
In regular expressions, the question mark makes the previous character optional.
hey thanks again randem......
That works fine for the folder structure, but if I use that and then type the domain name.....
ie: www.domain.com, that is also being redirected to the display.php.....
How would I get around that........
RewriteRule ^/([a-z]*)/?$ display.php?category=$1
Okay, now there's a slash required at the front of the URI.
I'm not sure if mod_rewrite starts from the domain name or from the URI, having never used it myself. If it starts from the domain name, you could use this:
RewriteRule ^www.yoursite.com/([a-z]*)/?$ display.php?category=$1
Curious, though... does this redirect the browser, or does it rewrite at the server? Seems to me that if it were redirecting the browser, you'd get a never-ending loop of redirection.