Reputation: 58
I have this kind of url:
http://www.example.com/activities?_activities=surf
What I'm trying to do is to get this other kind of url:
http://www.example.com/activities/surf
So what I need is just to remove ?_activities from url.
I tried to write some rewrite rule in htaccess but with no success.
Here what I tried:
RewriteCond %{QUERY_STRING} _activities=(.*) [NC]
RewriteRule (.*) /activities/%1/? [R=301,L]
What I'm wrong?
Upvotes: 0
Views: 88
Reputation: 106
Using the QSD (query string discard) flag removes the query string:
RewriteCond %{QUERY_STRING} _activities=(.*) [NC]
RewriteRule ^([^?]*) $1/%1 [R=301,L,QSD]
Applied to
http://www.example.com/activities?_activities=surf
the output will be
http://www.example.com/activities/surf
Note to the various flags:
Upvotes: 1