Post by sitedeveloper999 » Wed Nov 29, 2017 2:26 am

Having an interesting problem with redirects.

Previous version of the site was built on OC 2.x. New version is built on 3.0.2.0.

Had a lot of redirects set up, to handle incoming requests for outdated URLs.
Including, specifically, a pack of 200+ redirects to handle requests for product pages that used to have the .html or (later) .php extension - currently have just the product name, without any extension.

Previously, those redirects worked like a charm:

RewriteRule (^|[/-])SKU-AAZZ12345-?(\d*)\.(?:html?|php)$ http://www.example.com/new-product-name-AAZZ12345$2 [L,NC,R=301]

Here's how it worked previously:

Request for "www.example.com/item-type-SKU-AAZZ1245.php" (or "www.example.com/item-type-SKU-AAZZ1245.html")
Result: "www.example.com/new-product-nameAAZZ1245" (perfect)

Here's how it works now:

Request for "www.example.com/item-type-SKU-AAZZ1245.php"
Result: "https://example.com/index.php?_route_=SKU-AAZZ12345.php"

It's like it's TRYING to do something, but fails.

Also, the old site used HTTP with WWW, the new site uses HTTPS without WWW:

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

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Could these cause some sort of interference? They're placed in .htaccess BEFORE the item-level redirects.

Any advice?
Last edited by sitedeveloper999 on Wed Nov 29, 2017 5:32 am, edited 1 time in total.

New member

Posts

Joined
Tue Aug 09, 2016 2:09 am

Post by sitedeveloper999 » Wed Nov 29, 2017 5:32 am

Figured it out.
Apparently, htaccess CANNOT do a "2-step" redirect.
Because the new site is HTTPS instead of HTTP, and non-www, the RewriteRule has to specify the correct target EXACTLY, with HTTPS and without WWW.
So, trying to redirect from a wrong link to the right link, and THEN reformat the link with HTTPS and without WWW, does NOT work.

Leaving this question up in case someone else runs into this.

New member

Posts

Joined
Tue Aug 09, 2016 2:09 am
Who is online

Users browsing this forum: No registered users and 8 guests