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 redirect http://example.com/first-10.
  • http://example.com/first-10 internally rewrite /index.php?id=1&time=10

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -