Reputation: 1477
i have rule like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/show_video.php?id=[a-zA-Z0-9_-]+/(.*)$ /video/$1 [R]
</IfModule>
i want to redirect: http://www.domain.com/show_video.php?id=8 to http://www.domain.com/video/8/
show_video.php does not exist on the server.
how do i do that? my rule does not work.
Upvotes: 0
Views: 210
Reputation: 30051
You need to check the QUERY_STRING
in a rewrite condition, here is an example that probably would work:
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^show_video\.php$ /video/%1? [R=302,L]
Upvotes: 2
Reputation: 143906
You need to match against the query string using a RewriteCond
and the %{QUERY_STRING}
variable, then use the %1
to backreference the match:
RewriteCond %{QUERY_STRING} ^id=([a-zA-Z0-9_-]+)$
RewriteRule ^/?show_video.php$ /video/%1/? [R,L]
Upvotes: 1