Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need Help with 301 redirect using htaccess


navyhost

Recommended Posts

Hi guys,

 

We are in the process of moving categories around for our menu and we have moved some of our subcategories to main categories.

 

We have SEO URLS installed.

 

We are trying to set up 301 redirects in htaccess but the redirects aren't working correctly.

 

Our redirect looks like this:

 

Redirect 301 /hair-tools-hair-styling-brushes-c-116_167.html http://www.domainremoved.com/hair-styling-brushes-c-167.html

 

When the customer types the old address they are taking to this URL:

 

http://www.domainremoved.com/hair-styling-brushes-c-167.html?cPath=116_167

 

Is there a way to prevent the section in red? We have no idea why it is inputing this but basically what is happening is the site is recognizing the old location it was in.

 

Any assistance with this is greatly appreciated.

 

thank you

Sincerely

Mike

Link to comment
Share on other sites

Hi guys,

 

We are in the process of moving categories around for our menu and we have moved some of our subcategories to main categories.

 

We have SEO URLS installed.

 

We are trying to set up 301 redirects in htaccess but the redirects aren't working correctly.

 

Our redirect looks like this:

 

Redirect 301 /hair-tools-hair-styling-brushes-c-116_167.html http://www.domainremoved.com/hair-styling-brushes-c-167.html

 

When the customer types the old address they are taking to this URL:

 

http://www.domainremoved.com/hair-styling-brushes-c-167.html?cPath=116_167

 

Is there a way to prevent the section in red? We have no idea why it is inputing this but basically what is happening is the site is recognizing the old location it was in.

 

Any assistance with this is greatly appreciated.

 

thank you

 

you could try the following prior to the USU RewriteRules and after the RewriteBase

 

RewriteRule ^(.*)-c-116_167.html$ index.php?cPath=167&%{QUERY_STRING} [R=301,L]

Link to comment
Share on other sites

you could try the following prior to the USU RewriteRules and after the RewriteBase

 

RewriteRule ^(.*)-c-116_167.html$ index.php?cPath=167&%{QUERY_STRING} [R=301,L]

 

Hey,

 

Thanks a bunch,

 

This almost solved it, well it has, but the only problem I noticed since doing that is the subcategory links don't have "-" in the spaces any more. But what is throwing me off is that it seems like our old links are fine but the new categories we created today don't have any dashes. SO it is tuff to know if they are related with this change?

 

I had to change the code to this:

 

RewriteRule ^(.*)-c-116_167.html$ hair-styling-brushes-c-167.html [R=301,L]

Sincerely

Mike

Link to comment
Share on other sites

Hey,

 

Thanks a bunch,

 

This almost solved it, well it has, but the only problem I noticed since doing that is the subcategory links don't have "-" in the spaces any more. But what is throwing me off is that it seems like our old links are fine but the new categories we created today don't have any dashes. SO it is tuff to know if they are related with this change?

 

I had to change the code to this:

 

RewriteRule ^(.*)-c-116_167.html$ hair-styling-brushes-c-167.html [R=301,L]

 

What I posted was a rewriterule it will have no effect whatsoever on the way your subcategory links are presented, you must have adjusted the USU settings in admin.

Link to comment
Share on other sites

I am also having this same difficulty if the category code is the same in the old and new URLs then the redirect will show the new cateogry page

 

redirect 301 halloweencostumesuk.co.uk/Womens-Halloween-Costumes/c5/index.html http://www.halloweencostumesuk.co.uk/Women...s/c6/index.html

 

so instead of redirecting to the c6/index.html it takes you to the new c5/index.html???

 

Hope we can sort this out

Link to comment
Share on other sites

  • 4 weeks later...

Hello friends,

I want to redirect the following line:

‎/product_info.php?cPath=&products_id=14346‎

to

‎/product_info.php?products_id=14346‎

So, I added this code:

RewriteCond %{QUERY_STRING} cPath=&products_id=14346$

RewriteRule ^product_info\.php$ /product_info.php?products_id=14346 [R]

 

This works correctly.

But I want to redirect the all products instead of single product by using the same codes.

 

I appreciate your help.

Thanks,

Mousumi

 

 

I am also having this same difficulty if the category code is the same in the old and new URLs then the redirect will show the new cateogry page

 

 

 

so instead of redirecting to the c6/index.html it takes you to the new c5/index.html???

 

Hope we can sort this out

Link to comment
Share on other sites

RewriteRules imo should be avoided unless absolutely necessary.

 

Try the following in catalog/application_top.php

 

 

Find ..

 

  require(DIR_WS_FUNCTIONS . 'html_output.php');

 

Replace with ..

 

  require(DIR_WS_FUNCTIONS . 'html_output.php');
// BOF FWR redirect product_info cPaths
cpathRedirect();
// EOF FWR redirect product_info cPaths

 

at the very bottom before the closing ?> add ..

 

// BOF FWR redirect product_info cPaths
function cpathRedirect(){

 if( (basename($_SERVER['SCRIPT_NAME']) == FILENAME_PRODUCT_INFO) 
 && isset($_GET['cPath'])
 && (isset($_GET['products_id']) && is_numeric($_GET['products_id'])) ){

$newLocation = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['products_id']);
header("HTTP/1.0 301 Moved Permanently"); // redirect to the good version
header("Location: $newLocation"); // 301 redirect
 }
 return false;
}
// EOF FWR redirect product_info cPaths

 

I've had a few drinks so back up catalog/includes/application_top first.

Link to comment
Share on other sites

It works.

thanks Robert.

 

RewriteRules imo should be avoided unless absolutely necessary.

 

Try the following in catalog/application_top.php

 

 

Find ..

 

  require(DIR_WS_FUNCTIONS . 'html_output.php');

 

Replace with ..

 

  require(DIR_WS_FUNCTIONS . 'html_output.php');
// BOF FWR redirect product_info cPaths
cpathRedirect();
// EOF FWR redirect product_info cPaths

 

at the very bottom before the closing ?> add ..

 

// BOF FWR redirect product_info cPaths
function cpathRedirect(){

 if( (basename($_SERVER['SCRIPT_NAME']) == FILENAME_PRODUCT_INFO) 
 && isset($_GET['cPath'])
 && (isset($_GET['products_id']) && is_numeric($_GET['products_id'])) ){

$newLocation = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['products_id']);
header("HTTP/1.0 301 Moved Permanently"); // redirect to the good version
header("Location: $newLocation"); // 301 redirect
 }
 return false;
}
// EOF FWR redirect product_info cPaths

 

I've had a few drinks so back up catalog/includes/application_top first.

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

Thanks for your help.

Some pages have duplicate title tags in Google webmaster tools.

One example for duplicate title tag is Index of /images/peerless/spk722

This title tag comes in both of the URLS:

‎/images/peerless/spk722/?C=M;O=A

‎‎/images/peerless/spk722/?C=S;O=D

 

Thease URLS are not correct. The correct URL is

‎/images/peerless/spk722/

 

Could you please let me know how do I redirect ‎both of these pages

‎/images/peerless/spk722/?C=M;O=A

‎‎/images/peerless/spk722/?C=S;O=D

to

‎/images/peerless/spk722/

 

I appreciate your help.

Thanks,

Mousumi

 

RewriteRules imo should be avoided unless absolutely necessary.

 

Try the following in catalog/application_top.php

 

 

Find ..

 

  require(DIR_WS_FUNCTIONS . 'html_output.php');

 

Replace with ..

 

  require(DIR_WS_FUNCTIONS . 'html_output.php');
// BOF FWR redirect product_info cPaths
cpathRedirect();
// EOF FWR redirect product_info cPaths

 

at the very bottom before the closing ?> add ..

 

// BOF FWR redirect product_info cPaths
function cpathRedirect(){

 if( (basename($_SERVER['SCRIPT_NAME']) == FILENAME_PRODUCT_INFO) 
 && isset($_GET['cPath'])
 && (isset($_GET['products_id']) && is_numeric($_GET['products_id'])) ){

$newLocation = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['products_id']);
header("HTTP/1.0 301 Moved Permanently"); // redirect to the good version
header("Location: $newLocation"); // 301 redirect
 }
 return false;
}
// EOF FWR redirect product_info cPaths

 

I've had a few drinks so back up catalog/includes/application_top first.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...