Slight .htaccess Problem
Posted: Wed Feb 01, 2006 11:24 am
I have the following code in my .htaccess file for my website.
Now let me explain. I basically host a blog site for a few friends of mine and I make it possible for users to view their blog by visiting http://www.website.com/username instead of having to go to http://www.website.com/redirect.php?user=username.
The only problem with this is if somebody types in 'www.website.com/username/' instead of 'www.website.com/username' they will get a 404 error.
I seemed to have made some strides with the code, if I enter, for example, 'www.website.com/myusername/' it will redirect me to: http://www.website.com/myusername/redir ... myusername instead of just http://www.website.com/redirect.php?user=myusername
I think I'm really close. How should I modify the .htaccess code to alleviate the problem with the extra slash at the end?
Thanks in advance!
-influx
Code: Select all
RewriteEngine on
RewriteBase /
RewriteRule ^([A-Za-z_0-9-]+)((/)|())$ redirect.php?user=$1The only problem with this is if somebody types in 'www.website.com/username/' instead of 'www.website.com/username' they will get a 404 error.
I seemed to have made some strides with the code, if I enter, for example, 'www.website.com/myusername/' it will redirect me to: http://www.website.com/myusername/redir ... myusername instead of just http://www.website.com/redirect.php?user=myusername
I think I'm really close. How should I modify the .htaccess code to alleviate the problem with the extra slash at the end?
Thanks in advance!
-influx