I am having trouble setting up redirects from the old website pages to the new domain.
Opencart Version 1.5.3.1
I need to set up redirects for 5-10 pages of a similar format. For example:
/index.php?route=product/product&path=2_8&product_id=NNN
I would appreciate any assistance.
My .htaccess right now:
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
A redirect rule of the following kind is not working:
Redirect 301 /index.php?route=product/product&path=2_8&product_id=135 https://newdomain.com/new_page/
I assume you also have a
RewriteEngine Ondirective at the top of the file? (Otherwise, you need it!)As mentioned in comments, the
Redirect(mod_alias) directive matches against the URL-path only, so the above directive (that includes a query string) will never match.Since you are already using mod_rewrite, you should use mod_rewrite for this redirect as well and you need to combine this with a
RewriteConddirective in order to match the query string.For example, your rule should be like this at the top of the
.htaccessfile, before your existing directives:Note that the
=prefix on the preceding CondPattern makes this an exact string match, not a regex.The
QSDflag (Apache 2.4) discards the original query string from the redirected request.UPDATE:
That would suggest you are on an (outdated) Apache 2.2 server. In that case you would need to remove the query string by appending an empty query string to the substitution string. (The browser then strips the trailing
?from the request.)For example: