Jump to content

301 Redirecting Old Categories


Big Spender

Recommended Posts

In the latest CC5, I have a variety of categories which need removing, I want to squirt their juice at some other categories using 301 redirects.

 

I have the standard .htaccess included in CC5, but adding for example:

 

RewriteEngine On
Redirect 301 /index.php?_a=category&cat_id=4 http://www.domain.co.uk/new-category-name.html
 
OR
 
RewriteEngine On
Redirect 301 /category-name.html http://www.domain.co.uk/new-category-name.html
 
To redirect the old URLs just results in the old category being loaded (as I don't want to delete them yet)
 
I am guessing the initial CubeCart SEO URLs are interfering but .htaccess isn't really my strong point. Maybe I need to rename their SEO URLs to something else first, then try the 301 I have added...? Any pointers?
Link to comment
Share on other sites

"Maybe I need to rename their SEO URLs to something else first."

 

Having the web server tell the browser to try this different URL:

Redirect 301 /category-name.html http://www.domain.co.uk/new-category-name.html

when the old URL was used, should work fine.

 

The important point to verify is that CubeCart has recorded new-category-name as as an seo_path in the CubeCart_seo_urls database table.

Link to comment
Share on other sites

Okay, so the new category is in the SEO urls table so that is okay.

 

I made an error inputting the old category name into the htaccess originally which I have fixed, now when I try it redirects to the correct URL but the category shown is still the old category and the URL has the following appended:

 

/new-category.html?seo_path=old-category

Link to comment
Share on other sites

The querystring gets added by rewrite rules at the bottom of the htaccess file.

 

If that happens, then I would have to guess the

Redirect 301 from to

command is currently located after the rewrite command, or for some reason, the web server wants to run through all the commands before sending the 301 headers back to the browser.

 

What I believe needs to happen is for the web server to see the Redirect 301 and send the headers immediately.

Link to comment
Share on other sites

The answer to this is to add your redirect in this format:

RewriteRule ^shop/oldcat.html$ http://www.domain.co.uk/newcat.html[L,R=301]

Directly under here:

 

<IfModule mod_rewrite.c>
  RewriteEngine On
 
"The Redirect directive is part of mod_alias, while the rest of your htaccess file is using mod_rewrite. This means your redirect is getting applied along with the rule which matches (.*).html, so 2 things are getting applied to the same request. In this case, it's best to just stick with mod_rewrite."
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...