Reputation: 327
Hello i want to rewrite the following link:
http://websoftit.ro/social/profil.php?user=Ancuta Mirela
to http://websoftit.ro/social/Ancuta Mirela
.
Can someone tell me how to do that with mod_rewrite also maybe give me a link to a good documentation to learn myself how to do that?
Thnx in advance.
Upvotes: 1
Views: 112
Reputation: 785058
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+social/profil\.php\?user=([^\s&]+) [NC]
RewriteRule ^ /social/%1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^social/([^/]+)/?$ /social/profil.php?user=$1 [L,QSA]
I would suggest http://askapache.com as a good reference for learning mod_rewrite
.
Upvotes: 3
Reputation: 199
RewriteCond %{QUERY_STRING} (?:^|&)user=([^&]+) [NC]
RewriteRule ^ http://websoftit.ro/social/%1 [NE,R=301,L]
Upvotes: 0
Reputation: 2874
RewriteEngine On
RewriteRule ^social/([^/]+)$ social/profil.php?user=$1
Upvotes: 0