How would I rewrite:
http://localhost/profile.php?user=MaFi
to
http://localhost/user/MaFi
How would I rewrite:
http://localhost/profile.php?user=MaFi
to
http://localhost/user/MaFi
Try a RewriteRule like this:
RewriteRule ^profile.php?user=(.*)$ /user/$1 [R=301,L]
If you really want to redirect /profile.php?user=MaFi
to /user/MaFi
, try this rule:
RewriteCond %{QUERY_STRING} ^(([^&]*&)*)user=([^&]+)(&+(.*))?$
RewriteRule ^profile\.php$ /user/%3?%1%5 [L,R=301]
But if actually you want to rewrite /user/MaFi
internally to /profile.php?user=MaFi
, try this rule:
RewriteRule ^user/([^/]+)$ profile.php?user=$1 [L]
Gumbo your second code works for me but i need to change:
http://server.com/profile.php?user=MaFi
to
http://server.com/MaFi
any idea?
yoursite.com/MaFi ~ yoursite.com/profile.php?user=MaFi
<a href='/MaFi'>MaFi</a>
RewriteRule ^([^.]+)$ "/profile.php?user=$1" [L]
Or maybe...
yoursite.com/profile.php?user=MaFi ~ yoursite.com/MaFi
<a href='/profile.php?user=MaFi'>MaFi</a>
RewriteCond %{QUERY_STRING} user=(.+)
RewriteRule ^([^.]+)$ "/%1" [QSA]
I'm not 100% on these but hopefully they help.