Post by Jansuh » Fri May 25, 2018 12:23 am

Hi all,

I am currently migrating from my Zen cart webstore to opencart. Got myself a new hosting environment to work on so all i have to do when i am finished is switch the DNS of the domain. I have the basis opencart site set up, added all my products by hand and am now in the process of finalizing the migration with design of the homepage and setting up taxes, shipping methods etc.

I want to use 301 redirects from my old products and catergorys to my new opencart shop but i cannot seem to get it to work.
For example
I need http://www.pureandtimeless.nl/webshop/a ... -c-77.html to redirect to http://www.pureandtimeless.nl/webshop/Akoya-parels

Therefore i've added the following rule to my .htaccess
//301 Redirect Old File
Redirect 301 http://www.pureandtimeless.nl/webshop/a ... -c-77.html http://www.pureandtimeless.nl/webshop/Akoya-parels

And get an internal server error with this url as result: http://www.pureandtimeless.nl/webshop/A ... -c-77.html

I've tried various positions in the .htaccess file but no working result.

On the opencart site i have SEO urls enabled.

Is there anyone that can give me the solution?

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by Qphoria » Sat May 26, 2018 12:00 am

What is the link to the opencart store?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Jansuh » Mon May 28, 2018 12:52 am

There is no WWW url for this site yet. It runs on a development space i've gotten from my hosting provider.

Since it don't resolve on just the ip number i connect by setting an entry in my hostfile.

94.126.66.126 www.pureandtimeless.nl

I need to redirect about 550 produkt links, 10 categories and 20 information pages

Thanks in advance

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by MrPhil » Mon May 28, 2018 2:39 am

I don't know what your "development space" setup is, but I've heard of self-hosted PC-based *AMPP installations having trouble with "real" looking URLs (such as http://<your domain>/...). Check your redirection command syntax -- you may not need to give the domain name if you're on the same server and domain for both.

Anyway, manually redirecting 500+ products sounds a bit much. If you're just trimming off the ZenCart style -<code>-<number>.html, you might be able to do that with a handful of generic .htaccess rewrite statements. The capitalization used for old and new would have to be consistent, as would be the name format. You might even be able to come up with a way to simply ignore the -<code>-<number>.html in the URL, either in .htaccess processing or in the store PHP code (strip it off internally, while permitting it for old bookmarks and SE indexes), and not returning a 301 redirect.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by Jansuh » Mon May 28, 2018 11:55 pm

Thanks for the reply. Still not sure what to put in the .htaccess and where.

Anyone?

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by MrPhil » Tue May 29, 2018 2:32 am

Well, it depends exactly just what you're trying to do! Can you come up with a small set of rules such as "remove URL section ending in -c-numbers.html and capitalize the first letter, and return it with a 301 redirect code"? That sort of thing can probably be done fairly cleanly, so long as you do it in .htaccess before you get to any sections that process the modified URL. For simplicity, think twice about setting up your SEO to use a capital letter if the current one uses a lower case letter. Or, depending on whether anything is done in .htaccess to handle the new format (rather than in the PHP code), you might even be able to leave in the Zen Cart rewrite to simply handle the old Zen Cart format if that's what you receive.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by Jansuh » Sat Jun 02, 2018 8:03 pm

Ok, finally had some tome to look into this a little more.

I have the 301 redirects working now by adding:

#301 redirects
RewriteRule ^page$ /page.html [L,E=LOOP:1]
RewriteCond %{ENV:REDIRECT_LOOP} !1

to my .htaccess. now redirects like
RewriteRule ^webshop/contact_us.html$ /index.php?route=information/contact [R=301,L]
RewriteRule ^webshop/tahiti-parels-c-65.html$ /Tahiti-parels [R=301,L]

are working for me.

For my information pages and categories it isn't too much of a problem creating the proper redirect. For my products there might be a way to redirect
/webshop/14-karaat-geelgouden-oorhangers-met-barok-tahiti-parels-p-1392.html to /14-karaat-geelgouden-oorhangers-met-barok-tahiti-parels

So without the /webshop/ folder and strip of the p-1392.html part otherwise the .htaccess file needs around 600 entries and that might hurt my seo on load speed. So if anyone has a nifty formula to put above redirect in a formula for my products the would be awesome. I am not a code magician so every help is appreciated a lot.

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by MrPhil » Sat Jun 02, 2018 9:13 pm

If all you need to do is strip off -p-XXXXX.html, -c-XXXXX.html, etc. from incoming URLs, that should be possible. Try something like

Code: Select all

RewriteCond  %{REQUEST_URI}  ^(.*)-[pc]+-\d+\.html$ 
RewriteRule  .  %1  [R=301,L]
after RewriteEngine On but before any OpenCart SEO rewrites. Add more letters to the "pc" list as necessary (you might even be able to replace [pc] with [a-z] or \w). Give that a try and see if it does the job. If not, there might be other ways to approach it, either in .htaccess or in PHP code. The bottom line is that you should not have to list all these URLs individually -- there should be a way to treat them generically.

Mind you, if you also need to capitalize some letter(s) (or lowercase them), that is a separate issue which could get quite complicated. It might be better to handle that in PHP code.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by Jansuh » Mon Jun 04, 2018 12:57 am

Works great Phil,

Any magic code to strip of the /webshop/ part at the front of the original url?

This will save me so much work. Thanks!

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by Jansuh » Mon Jun 04, 2018 1:54 am

Figured it out already.

RewriteRule ^webshop/(.*)$ /$1 [R=301,NC,L]
RewriteCond %{REQUEST_URI} ^(.*)-[pc]+-\d+\.html$
RewriteRule . %1 [R=301,L]

Does the trick. Thanks again

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by MrPhil » Mon Jun 04, 2018 8:10 pm

Ah yes, I missed the "webshop" needing to go away. You probably want to combine the two, because now you have two "301" redirects happening (the first to strip off the webshop, and the second to strip off the suffix). Search engines will penalize you multiple redirects on one URL. It may be as simple as removing the R=301 and L flags from the first rewrite, so that it falls through (without "webshop") to the second rewrite.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by Jansuh » Mon Jun 04, 2018 9:10 pm

I will test that, thanks

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by Jansuh » Mon Jun 04, 2018 9:45 pm

I'm gonna need your expertise one last time Phil,

I have some remaining pages that are in he current format:
www.pureandtimeless.nl/webshop/page.html?id=11 that needs to resolve to www.pureandtimeless.nl/alles-over-parels

Did some google searching and come to this solution wich works
RewriteCond %{QUERY_STRING} id=11
RewriteRule ^index\.php$ alles-over-parels/? [L,R=301]

But when i add a second one with the same rule it gives a "ERR_TOO_MANY_REDIRECTS" error.
RewriteCond %{QUERY_STRING} id=82
RewriteRule ^index\.php$ hoe-kunt-u-zien-of-parels-echt-zijn-echte-parels-herkennen [L,R=301]

I think i am close but can't find it. Kindly advice

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm


Post by Jansuh » Mon Jun 04, 2018 10:12 pm

Got it figured out.

Forgot the /? at the end of the rule. Overlooked that.

Cheers

New member

Posts

Joined
Fri Apr 20, 2018 8:13 pm

Who is online

Users browsing this forum: No registered users and 8 guests