Jump to content

301 Redirect issues - .htaccess


Recommended Posts

Hi all, I'm experiencing a 301 redirect issue.  In my .htaccess file I've put in 301 redirects for pages that existed on the previous version of the site.  For some reason it will redirect properly on the 1st level subdirectory but if their are more than one sub-directories in the URL to be redirected it does something interesting.

 

 

Redirect 301 /some-information http://www.mywebsite.com/content/some-information.html  (This works fine)

 

Redirect 301 /some-information/more-info http://www.mywebsite.com/content/more-info.html  (This does not work)

 

This is what happens when redirected from Redirect 301 /some-information/more-info

 

http://www.mywebsite.com/content/some-information.html/more-info  (This is the problem)

 

 

As you can see above, it follows the rules as designated in Redirect 301 /some-information but it adds /more-info to the end of http://www.mywebsite.com/content/some-information.html . Basically, if it's only one sub-category it works and if there is a second sub-category it follows the original rules and simply appends the second sub-category's name to the end after the .html.

 

This should be redirecting to http://www.mywebsite.com/content/more-info.html  , not http://www.mywebsite.com/content/some-information.html/more-info

 

I've attached a screenshot of my BO > PREFERENCES > SEO & URLs

post-865259-0-14458100-1436241373_thumb.png

Edited by nakecorp2 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

We found somewhat of a fix.  I'd hoped to have heard anything from anyone one here, but no dice.  Anyway, we moved the RewriteEngine on statment to the very top of the htaccess file. 

 

Just below the RewriteEngine On statement we placed our www redirect:

 

RewriteCond %{HTTP_HOST} ^ourwebiste.com$
RewriteRule ^(.*)$ "http\:\/\/www\.ourwebiste\.com\/$1" [R=301,L]

 

Just below this we placed all of our 301 redirects, but there's a catch.  We had to do something new that we'd never had to do before.  For any url strings that had multiple sub-directory references we had to use the code below.

 

RedirectMatch 301 ^/product-category/product-name-here http://www.ourwebsite.com/product-name-here.html

RedirectMatch 301 ^/product-category/another-subcategory-here/product-name-here-2 http://www.ourwebsite.com/product-name-here-2.html

 

If the statement Redirect 301 / was used instead of RedirectMatch 301^/ we would get the wierd redirect to something like

ourwebsite.com/product-name-here.html/category .

 

The Redirect 301 / statement that normally worked for everything, now only worked for single instances of the redirect or top level (Top or single directory) such as below.

 

Redirect 301 /product-category http://www.ourwebsite.com/product-name-here.html

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...