user_x
asked on
Mod_rewrite with no suffix - but wont pass variable
I am using mod rewrite to make a url easier to enter. The idea is to call the file with parameters with the short url. I have a version that allows this url:
http://example.com/members/members.php?uid=00000
to be entered as this url:
http://example.com/members/00000/
but I need a user to be able to enter with and without a trailing slash
http://example.com/members/00000
I can't decide how to add the second rule or combine them. When i remove the slash for the suffix, it errors out to 404. Anyone have a good idea?
http://example.com/members/members.php?uid=00000
to be entered as this url:
http://example.com/members/00000/
but I need a user to be able to enter with and without a trailing slash
http://example.com/members/00000
I can't decide how to add the second rule or combine them. When i remove the slash for the suffix, it errors out to 404. Anyone have a good idea?
RewriteBase /members/
RewriteEngine On
RewriteRule ^([^/]*)/$ members.php?uid=$1 [L]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try it without using RewriteBase:
RewriteEngine On
RewriteRule members/([^/]*)/?$ members.php?uid=$1 [L]
ASKER
Still a no go, sorry. It works with the original rule but not without the trailing slash. With those two suggestions, it does not get the url for the variable.
RewriteRule ^(.*)$ members.php?uid=$1 [L,QSA]
That will rewrite 0000/ -> members.php?uid=0000/ - not sure if it hurts.
Btw, for debugging you can enable Rewrite Logging in the the server or virtualhost context.
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 9
That will rewrite 0000/ -> members.php?uid=0000/ - not sure if it hurts.
Btw, for debugging you can enable Rewrite Logging in the the server or virtualhost context.
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 9
ASKER
I used Kravimir's first suggestion last night but had a mistake in the expression. I ended up using this:
RewriteRule ^([0-9-]+)/?$ members.php?uid=$1 [L]
Thanks Kravimir and thank to everybody that helped.
RewriteRule ^([0-9-]+)/?$ members.php?uid=$1 [L]
Thanks Kravimir and thank to everybody that helped.
ASKER
Thanks, that got it after all.
ASKER
Thanks,
userx