Post by takayuki » Sat Mar 21, 2020 12:13 pm

Hi,

I'm trying to do a simple 301 redirect via htaccess with my Opencart 2.3 site.

old url: http://domain.com/PokPlushToy/PlushToys/ChikoPlush
the url I want to redirect to: https://domain.com/PokPlushToy


Here's my rewrite rule:

Code: Select all

RewriteRule ^PokPlushToy/PlushToys/ChikoPlush$ index.php?route=category/PokPlushToy [R=301,NC,L]
But this ain't werkin. It results in this:

https://domain.com/PokPlushToy?_route_= ... ChikoPlush

thanks for any help here.

PS. my rule is before this rule:
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

but the url is still getting fouled.

Dave
Last edited by takayuki on Sat Mar 21, 2020 9:12 pm, edited 1 time in total.

New member

Posts

Joined
Thu Aug 13, 2009 10:16 pm

Post by uksitebuilder » Sat Mar 21, 2020 6:42 pm

Please post full .htaccess content.

Order of commands / rules is important in .htaccess

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by takayuki » Sat Mar 21, 2020 9:11 pm

Thanks for the reply. Here's the full file

Code: Select all

# SEO URL Settings
RewriteEngine On

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]

#heres the one that doesnt work...
RewriteRule ^PokPlushToy/PlushToys/ChikoPlush$ https://domain.com/PokPlushToy [R=301,NC,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]

RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule (.*) https://domain.com/$1 [R=301,L]

RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ https://domain.com? [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$  https://domain.com/$1 [L,R=301]
Last edited by straightlight on Sun Mar 22, 2020 6:36 am, edited 1 time in total.
Reason: Please add the code tags!

New member

Posts

Joined
Thu Aug 13, 2009 10:16 pm

Post by uksitebuilder » Sun Mar 22, 2020 6:28 am

Code: Select all

# SEO URL Settings
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule (.*) https://domain.com/$1 [R=301,L]

RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ https://domain.com? [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]

RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]

#heres the one that doesnt work...
RewriteRule ^PokPlushToy/PlushToys/ChikoPlush$ https://domain.com/PokPlushToy [R=301,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]
Other than the above, I cannot see why it would not work unless you have some kind of SEO URL modification installed

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by takayuki » Sun Mar 22, 2020 8:54 am

thanks for your help, UKsitebuilder. unfortunately, i still get the wonky URL with the route=blahblah tacked on which 404s it.

I think you are right, there has to be another variable affecting things. it *should* work.

New member

Posts

Joined
Thu Aug 13, 2009 10:16 pm
Who is online

Users browsing this forum: Baidu [Spider] and 30 guests