apache - .htaccess with two parameters redirects to a 404 page -
i want redirect /index.php?id=1&time=10
/first-10
.
.htaccess:
rewriteengine on rewritecond %{query_string} id=1&time=10 rewriterule ^index\.php$ /first-10/? [l,r=301]
when access /index.php?id=1&time=10
redirects /first-10/
, it's 404 page. please notice last slash also.
where problem?
you need internally rewrite old-original format.
must use the_request
avoid infinite loop
rewriteengine on rewritecond %{the_request} \s/(?:index\.php)?\?id=1&time=10\s [nc] rewriterule ^ /first-10? [r=301,l] rewriterule ^first-10$ /index.php?id=1&time=10 [l]
- both
http://example.com/index.php?id=1&time=10
,http://example.com/?id=1&time=10
redirecthttp://example.com/first-10
. http://example.com/first-10
internally rewrite/index.php?id=1&time=10
Comments
Post a Comment