Oscommerce to OpenCart Redirects - apache

The way that Oscommerce SEO Friendly URLs work, is that they are generated from a product or category title followed by a p for product and c for category, then the product or category ID. For categories, each parent directory ID is also used.
for example:
https://example.com/jeep-pinion-gears-c-284_845.html
over the course of many years, products and categories get edited and moved therefore changing the URL. However, all the old URL's still resolved because pages are served strictly based off of the last part of the URL. It looks for the c or p and the ID's. SEO is still able to be maintained.
For Example:
https://example.com/jeep-pinion-gears-c-284_845.html
https://example.com/jeep-pinion-gears-and-accessories-c-284_845.html
https://example.com/jeep-pinion-gears-c-284_1234_845.html
https://example.com/ring-pinion-gears-c-845.html
Would all load the same content.
I've recently changed over to OpenCart where I used the latest URL for each product and category from the OsCommerce store. However, all the of Old Oscommerce URL's don't work.
I was originally writing some regex redirects to match the ID's but I'm running into redirect loop issues.
Does anyone any any ideas on a different approach?

If there is a way to derive the new OpenCart URL from your OsCommerce SEO URLs
RewriteCond %{REQUEST_URI} !^/.*?-[cp]-\d+\.html$
RewriteCond %{REQUEST_URI} ^/(.*?)-([cp])-[\d_]*?(\d+)\.html$ [NC]
RewriteRule (.*) https://new.example.com/%2-%3.php [R=301,L]
The important part here is the stop not rule to prevent looping redirects.
put it below others rewrites, removing a trailing slash or the www-subdomain, or http to https rewriting.
If three is no "simple relationship" between the two URLs you are out of luck and have to write a redirect for each of them. You should be able to generate the rules using the SEO URLs stored in the DB.
Redirect 301 /old-page.html http://www.example.com/new-page.html
Maybe a PHP redirect could be helpful too?
header("Location: http://www.example.com/new-page.html", true, 301);
exit();

Related

htaccess 301 redirect for webshop transfer

I searched stackoverflow but couldn't find a solution that fits my need. On top of it, if must admit, that regex is a pretty difficult thing for me. So here is the thing:
I have a new webshop (domain-new.com) that has basically the same products of old shop (weird product urls, weird categories, everything weird, ...) but on a new technology, new domain and proper URLs. Thus, I would like to close the old shop and transfer the SEO rankings with a 301 redirect to the new domain/shop.
My solution is that the old shop/domain serves a .htaccess file with a lot of links:
RewriteEngine On
Redirect 301 / http://www.domain-new.com/ ###front page
Redirect 301 old-weird-product-path1 http://www.domain-new.com/new-product1.html
Redirect 301 old-weird-product-path2 http://www.domain-new.com/new-product2.html
Redirect 301 old-weird-product-path3 http://www.domain-new.com/new-product3.html
Redirect 301 old-weird-product-path4 http://www.domain-new.com/new-product4.html
I could manage to link about 300 products and categories but can't manage to do the hole list of 5000 products and categories.
Is there a way to add a line of code that says: "and for everything else, thats not listed above, redirect to the front page of the new webshop?
Thanks in advance and sorry, if the question was answered somewhere else. I couldn't find the proper solution.
This may be possible with regex match if you have a common pattern in weird urls.
Then Regex not match common url pattern and redirect to home page of new website something like
RewriteEngine on
RewriteRule [^old-weird-product-path] http://www.domain-new.com/ [R=301,L]
You may have to refine it as per url structure.

Redirecting old unused domain to new domain will help to increase Google authority?

I have been doing blogging since 5 years back and from last year i had stopped blogging and delete the domain content. (During last year all pages are removed from indexed )
now I had purchased a new domain BlogTechie and i am planning to 301 redirect that old domain to new domain.
Is It helped to gain SEO authority in Google or I should start from scratch without worrying about old domain.
I am also adding settings in webmaster tools to inform Google for the change.
SEOs attribute a large portion of most search engines' ranking algorithms to link-based factors. It's possible there may be old links to your pages out there on the internet on other websites. You can capitalize on this if you still own the old URL and boost your new domain's ranking with redirects.
If you know some of your older content's URLs, it might make sense to have a one to one redirect to the new page. If you're using apache, you can do this with an .htaccess file:
RewriteEngine On
RedirectMatch 301 /folder/oldpage.php http://www.newdomain.org/newpage.php
Anything remaining can redirect to the root.
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]
Check out SEO Moz for more explanation on this: http://moz.com/learn/seo/redirection

Redirect domain to a new domain, exclude one url + send all post and get data

I've migrated my website to a new domain, and now facing some difficulties.
After someone purchases and pays on an external website, he is returned to the old site, where he is redirected to the new website with the following rule:
RewriteCond %{HTTP_HOST} !^oldsite\.com$
RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]
My problem is that when he is redirected to the new domain, he loses all the data that is returned about the purchase (status and so on).
I figured I can do two things - process the purchase on the old domain (I can't currently change the return URL from the payment company). in order to do that, I need to exclude the specific URL, which I tried to do by adding this before the previous code:
RewriteCond %{HTTP_HOST} !^purchase\_online\_td.\php$
But nothing, not working. tried many variations.
So I need either to solve the POST data not redirected, or the exclusion of the URL.
Either will be great due to the urgency of the matter...
Thanks for your thoughts.
Try removing the underscore escapes, as you don't need them. Also, you had the wrong variable
RewriteCond %{REQUEST_URI} !^purchase_online_td\.php$
What you need is to edit the DNS records of your old domain so that both point to your new site.
And then update your link structure.
So there will be no redirecting from the old domain then.

Proper 301 redirect for sites

I have a bit of a complex question. I am moving sites from
http://www.hikingsanfrancisco.com
to
http://www.comehike.com
The directory structures will not be the same throughout both sites. What are some of the best practice things I can do in order to retain most of my existing SEO strength in both the general domain and individual pages for searches related to the other pages?
Thank you,
Alex
If most of the URLs are staying the same and just the domain is changing, you could create an .htaccess file in the root folder at the old site with the following:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.comehike.com/$1 [R=301,L]
This will make hikingsanfrancisco.com/some-page go to comehike.com/some-page.
Otherwise in that same htaccess file you could add a line for each redirect. So if hikingsanfrancisco.com/big-hikes is now going to comehike.com/even-bigger-hikes the redirect would look like:
Redirect 301 /big-hikes http://www.comehike.com/even-bigger-hikes
That 301 tells Google to now consider the new URL correct.
To redirect the whole site no matter what to the new URL you could use this:
Redirect 301 / http://www.comehike.com/
A 301 Redirect, page by page, is the best option (If you can use regular expressions is easier). Redirect the old page to a page in the new site with similar content.
Use the change of address tool in Google Webmasters tools.
Try to contact some of yours referrals to change the links that target your site.

Using Apache mod_rewrite to remove sub-directories from URL

I'm managing an instance of Wordpress where the URLs are in the following format:
http://www.example.com/example-category/blog-post-permalink/
The blog author did an inconsistent job of adding categories to posts, so while some of them had legitimate categories in their URLS, at least half are "uncategorised".
I can easily change Wordpress to render the URL without the category name (e.g., http://www.example.com/blog-post-permalink/), but I'd like to create a mod_rewrite rule to automatically redirect any requests for the previous format to the new, cleaner one.
How can I use a mod_rewrite recipe to handle this, taking into account that I want to honor requests for the real WordPress directories that are in my webroot?
Something as simple as:
RewriteRule ^/[^/]+/([^/]+)/?$ /$2 [R]
Perhaps would do it?
That simple redirects /foo/bar/ to /bar.