Zen Cart Logo
Forums / General Questions / 301 Redirects Not Working Fully

301 Redirects Not Working Fully

Views: 2,464

Results 1 to 10 of 10
14 Nov 2012, 10:39 PM
#1
higherthan avatar

higherthan

New Zenner

Join Date:
Nov 2012
Posts:
1
Plugin Contributions:
0

301 Redirects Not Working Fully

A category was moved and it created a new url so we had to create a 301 redirect in htaccess for the old url to the new one however the redirect is not working fully.

The old url is http://www.worklinesafety.co.uk/safety-footwear-rigger-boots-c-6_32.html and the new one is http://www.worklinesafety.co.uk/safety-boots-rigger-boots-c-6_119_32.html

we placed in the htaccess the following code:

Redirect 301 /safety-footwear-rigger-boots-c-6_32.html [url]http://www.worklinesafety.co.uk/safety-boots-rigger-boots-c-6_119_32.html[/url]

The redirect does cause a redirect however it loads as http://www.worklinesafety.co.uk/safety-boots-rigger-boots-c-6_32.html As you can see the url is missing _119 Category ID. :wacko:

We use the Ultimate SEO URL plugin.

We do have a few other 301 redirects that work 100% however we cannot figure this out.:no:

Here is our full htaccess code incase there are any conflicts happening:
##### NOTE: Replace /shop/ with the relative web path of your catalog in the "Rewrite Base" line below:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /


# From Ultimate SEO URLs
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-c-(.*).html$ index\.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-m-([0-9]+).html$ index\.php?main_page=index&manufacturers_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pi-([0-9]+).html$ index\.php?main_page=popup_image&pID=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pr-([0-9]+).html$ index\.php?main_page=product_reviews&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pri-([0-9]+).html$ index\.php?main_page=product_reviews_info&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-ezp-([0-9]+).html$ index\.php?main_page=page&id=$2&%{QUERY_STRING} [L]

# For Open Operations Info Manager
RewriteRule ^(.*)-i-([0-9]+).html$ index\.php?main_page=info_manager&pages_id=$2&%{QUERY_STRING} [L]

# For dreamscape's News & Articles Manager
RewriteRule ^news/?$ index\.php?main_page=news&%{QUERY_STRING} [L]
RewriteRule ^news/rss.xml$ index\.php?main_page=news_rss&%{QUERY_STRING} [L]
RewriteRule ^news/archive/?$ index\.php?main_page=news_archive&%{QUERY_STRING} [L]
RewriteRule ^news/([0-9]{4})-([0-9]{2})-([0-9]{2}).html$ index\.php?main_page=news&date=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^news/archive/([0-9]{4})-([0-9]{2}).html$ index\.php?main_page=news_archive&date=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+)-comments.html$ index\.php?main_page=news_comments&article_id=$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+).html$ index\.php?main_page=news_article&article_id=$2&%{QUERY_STRING} [L]

# All other pages
# Don't rewrite real files or directories
RewriteCond %{REQUEST_FILENAME} !-f [NC] 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ index\.php?main_page=$1&%{QUERY_STRING} [L]

rewritecond %{http_host} ^worklinesafety.co.uk [nc]
rewriterule ^(.*)$ http://www.worklinesafety.co.uk/$1 [r=301,nc] 



Redirect 301 /safety-footwear-rigger-boots-c-6_32.html http://www.worklinesafety.co.uk/safety-boots-rigger-boots-c-6_119_32.html
Redirect 301 /safety-footwear-shoes-c-6_33.html http://www.worklinesafety.co.uk/safety-footwear-safety-shoes-c-6_33.html
Redirect 301 /safety-boots-ankle-boots-c-6_31.html http://www.worklinesafety.co.uk/safety-boots-ankle-boots-c-6_119_31.html
14 Nov 2012, 11:04 PM
#2
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,284
Plugin Contributions:
38

Re: 301 Redirects Not Working Fully

Couple of issues to explain why it will never work....

The original page (safety-footwear-rigger-boots-c-6_32.html) still works

The original page (safety-footwear-rigger-boots-c-6_32.html) carries the same string/category assignment as the old (safety-boots-rigger-boots-c-6_119_32.html)

The flaw, which has always existed in USEO is that the following urls will ALL load the same page.....

safety-boots-rigger-boots-c-32.html
-c-6_32.html
something-something-something-c-6_119_32.html

~Melanie

14 Nov 2012, 11:09 PM
#3
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: 301 Redirects Not Working Fully

You should place any 301 redirects BEFORE any RewriteRules. Otherwise your URL may be caught by the RewriteRules before the 301 is issued. (this is why you are losing the new category path)

You are also missing a required block to send invalid URLs to Zen Cart's page_not_found from your .htaccess file.

It appears from the .htaccess file you posted you are running an older version of "Ultimate SEO URLs". If you are on Zen Cart 1.5 you may wish to look into upgrading to the latest version.

14 Nov 2012, 11:19 PM
#4
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: 301 Redirects Not Working Fully

mprough:

The flaw, which has always existed in USEO is that the following urls will ALL load the same page.....

safety-boots-rigger-boots-c-32.html
-c-6_32.html
something-something-something-c-6_119_32.html
This is not true in the current versions.

You will notice the following line in the .htaccess file:

RewriteRule ^(.*)-c-(.*).html$ index\.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]

This line sends the URL generated by "Ultimate SEO URLs" to the Zen Cart dynamic URLs. Wait What? Yes, "Ultimate SEO URLs" internally uses the same URLs as Zen Cart!

So "something-something-something-c-6_119_32.html" becomes "index.php?main_page=index&cPath=6_119_32".
And "safety-boots-rigger-boots-c-32.html" becomes "index.php?main_page=index&cPath=32".
And "-c-6_32.html" becomes "index.php?main_page=index&cPath=6_32".

Newer versions of "Ultimate SEO URLs" use a slightly different .htaccess file with optimizations for performance.

1 Dec 2012, 6:14 AM
#5
jenchord avatar

jenchord

New Zenner

Join Date:
May 2011
Posts:
68
Plugin Contributions:
0

Re: 301 Redirects Not Working Fully

Hello,
I'm hoping that perhaps you can help me. I am trying to redirect one of my product info pages to a defines page (don't ask why!).
Here's the code in my htaccess:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^main_page=document_product_info&cPath34&products_id=130$ [NC]
RewriteRule ^(.*)$ http://mysite/index.php?main_page=about_us [R=301,L]

I am pretty certain that the rewrite condition is correct as I've gotten the redirect to work "sometimes" -- meaning that messing with the rewrite rule, it previously redirected to my homepage instead of my about us page.
I've messed around with the the last line some more, and now it doesn't redirect to anywhere.

I don't know what I'm doing when it comes to the htaccess. The code snippets above I've gotten from mixing and matching from other posts.
I think all I need is a correction on the rewrite rule.

Thanks in advance for any suggestions!

1 Dec 2012, 11:36 AM
#6
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,284
Plugin Contributions:
38

Re: 301 Redirects Not Working Fully

Like this

RewriteCond %{QUERY_STRING} main_page=document_product_info&cPath34&products_id=130
RewriteRule (.*) http://mysite/index.php?main_page=about_us$1? [R=301,L]

In the last line depending on how the resulting url looks, IE appended or not, then you may need to change to

RewriteRule (.*) http://mysite/index.php?main_page=about_us$1 [R=301,L]

or

RewriteRule (.*) http://mysite/index.php?main_page=about_us [R=301,L]

Cheers,
Melanie

1 Dec 2012, 8:27 PM
#7
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: 301 Redirects Not Working Fully

You may also need to use multiple RewriteCond lines if the parameters are not always in the same order.

RewriteCond %{QUERY_STRING} main_page=document_product_info
RewriteCond %{QUERY_STRING} cPath=34
RewriteCond %{QUERY_STRING} products_id=130
RewriteRule ^index.php$ http://mysite/index.php?main_page=about_us [R=301,L]
1 Dec 2012, 8:55 PM
#8
jenchord avatar

jenchord

New Zenner

Join Date:
May 2011
Posts:
68
Plugin Contributions:
0

Re: 301 Redirects Not Working Fully

Thanky much!

This "RewriteRule (.*) http://mysite/index.php?main_page=about_us [R=301,L]" worked.

Thanks again.

1 Dec 2012, 9:09 PM
#9
jenchord avatar

jenchord

New Zenner

Join Date:
May 2011
Posts:
68
Plugin Contributions:
0

Re: 301 Redirects Not Working Fully

For the rewrite conditions, both this:

RewriteCond %{QUERY_STRING} main_page=document_product_info&cPath**=**34&products_id=130

and this:

RewriteCond %{QUERY_STRING} main_page=document_product_info
RewriteCond %{QUERY_STRING} cPath=34
RewriteCond %{QUERY_STRING} products_id=130

worked.

Thanks!

3 Dec 2012, 10:05 PM
#10
jenchord avatar

jenchord

New Zenner

Join Date:
May 2011
Posts:
68
Plugin Contributions:
0

Re: 301 Redirects Not Working Fully

On a slightly different topic, I am using the "ceon uri mapping" module to make my category and product urls better looking (and I've heard it MIGHT improve SEO).
Anyway, I've noticed that there are duplicate pages for lower and upper-case letters. For example, one of my styled urls
"mysite.com/Fashion-Clothes" can also be found through the url, "mysite.com/fashion-clothes".

Does google see this as two different pages with the same content?
If so, is there a simple redirect I can do in htaccess so that any upper-case-letter urls get redirected to lower-case-letter pages?

Thanks for letting me tap into your guys' higher knowledge :D