Pergunta

RewriteRule ^cart.php(.*?) https://www.DOMAIN.com/buy-now/$1 [R=301,L]
RewriteRule ^buy-now/(.*?) cart.php$1 [QSA]

This creates a redirect loop. What i want is for cart.php to redirect to /buy-now/ (carrying query strings) and /buy-now/ to actually parse as cart.php.

Foi útil?

Solução

Yes this will sure cause loop. You will need to use %{THE_REQUEST} to avoid this looping.

Have your rule like this:

RewriteEngine On

RewriteCond %{THE_REQUEST} /+cart\.php [NC]
RewriteRule ^cart\.php(.*)$ /buy-now/$1 [R=301,L,NC]

RewriteRule ^buy-now/(.*)$ /cart.php$1 [L,NC]
  • THE_REQUEST variable represents original request received by Apache from your browser and it doesn't get overwritten after execution of some rewrite rules.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top