Forum Moderators: phranque
I'm having a bit of a problem with mod_rewrite. I've read the manual and various tutorial sites, and just can't get it working.
All i want to do is do a redirection like this:
www.domain.com/username >> www.domain.com/script.php?user=username
If someone could tell me how to do this i'd be grateful.
rewriteEngine on
rewriteRule ^/([^yse]*)$ /yse/index.php?action=profile;user=$1 [L]
The folder of the script is /yse so i'm trying to say any request that isn't that will put the request onto the end of the php query.
Requests for /yse are loading as normal, but if you try anything else including a valid username you just get a 404
RewriteEngine on
RewriteCond %{REQUEST_URI} !/yse
RewriteRule ^/(.*)$ /yse/index.php?action=profile;user=$1 [L]
Jim
This is my completed code as it stands, seems to work fine.
rewriteEngine on
RewriteCond %{REQUEST_URI}!/yse
RewriteRule ^/([a-z0-9]*)$ /$1/ [R]
RewriteRule ^/(.*)/$ /yse/index.php?action=profile;user=$1 [L]
First rule adding a slash, and at the same time having the effect of making images and other files in the site root continue to work.
Second rule assuming there is a slash and rewriting