Link to home
Start Free TrialLog in
Avatar of sharingsunshine
sharingsunshineFlag for United States of America

asked on

Why Is Rewrite Rule Throwing Error Message "Moved Permanently?"

This is a follow-on to this question https://www.experts-exchange.com/questions/29120630/How-To-Enable-Rewrite-On-Linux-2.html - I followed the advice but forgot that wordpress will overwrite what is within the wordpress block so I am now moving it out of the block.

# END W3TC Page Cache core

RewriteCond %{QUERY_STRING} controller=product [NC]
RewriteCond %{QUERY_STRING} id_product=26 [NC]
RewriteRule ^/?index\.php$ /product/geranium-15-ml-100-pure-essential-oil/ [NC,R=301]

RewriteCond %{QUERY_STRING} controller=cms [NC]
RewriteCond %{QUERY_STRING} id_cms=([0-9]+)\%3F [NC]
RewriteRule ^/?index\.php$ /index.php?controller=cms&id_cms=%1 [NC,R=301]

RewriteCond %{QUERY_STRING} controller=product [NC]
RewriteCond %{QUERY_STRING} id_product=([0-9]+)\%3F [NC]
RewriteRule ^/?index\.php$ /index.php?controller=product&id_product=%1 [NC,R=301]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Open in new window


The first re-write rule produces this error:  

https://gyazo.com/9741f64223879ee3f42407f1985e4d5e

The other 2 rules work fine so why is this rule not working and producing this error?
ASKER CERTIFIED SOLUTION
Avatar of Dr. Klahn
Dr. Klahn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sharingsunshine

ASKER

You're correct, but it also needs a "?" at the end to drop the query string.

Thanks for your help.