Results 1 to 7 of 7

Thread: 301 redirect via htaccess help please

  1. #1
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default 301 redirect via htaccess help please

    I have been trying to figure out what I have been doing wrong with my 301 redirects but I am not getting the results required (this is a WordPress web site).

    We have made changes to our site by removing certain sections and now just want to point those old URL's to a replacement

    for example

    OLD: /art-prints-gifts-and-decor/zazzle-gift-shop/accessories/bags/
    NEW: /portfolio-shop/

    via using

    redirect 301 /art-prints-gifts-and-decor/zazzle-gift-shop/accessories/bags/ /portfolio-shop/

    however when i visit the old URL it redirects to /portfolio-shop/bags/

    (why is it adding bags/?

    How can I fix this please.

    GW
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Shouldn't the syntax be
    Code:
    Redirect 301 /art-prints-gifts-and-decor/zazzle-gift-shop/accessories/bags/ http://mywebsite.com/portfolio-shop/
    ?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    gwmbox (05-16-2016)

  4. #3
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default

    But it is the same web site, just a change of some url's or, as above, a complete removal of some no longer active urls, so I want to redirect to a page (as set) instead of just a 404 message.

    EDIT: HMM - it appears you are right would not have thought that would make such a difference - but thanks as it is working now

    EDIT 2 - Nope that did not change it. the same applies as per my first post

    EDIT 3 - This is a https secure site as well if that makes a difference.
    Last edited by gwmbox; 05-16-2016 at 05:52 AM.
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  5. #4
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default

    Stupid thing works fro some and not others.

    At least I know I have the right syntax now though
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  6. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Just as a note here, I did a quick search and all of the examples I saw used the full URL for the redirected TO page. So you gotta think that's important. Perhaps, and especially if it's https, you might want to do two or more redirects. One from the https partition and one from the http one. Other possible FROM addresses would be the https://www and the https:// without the www and likewise for the http versions of those. Basically, what I'm saying is that it cannot hurt to cover all possible bases with the FROM address(es) and of course make them all redirect to the same desired TO address. One per line, each with the desired TO address on the right in the .htaccess file.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. The Following User Says Thank You to jscheuer1 For This Useful Post:

    gwmbox (05-17-2016)

  8. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Additional, just in case it *is* an issue, if you *do* have both http:// and http://www versions of the same url able to resolve, it will be better for SEO to pick only one and globally redirect to that. Allowing the use of both variations can really mess with your analytics and dilute link-juice.

    To fix that, you can redirect to www versions like this;
    Code:
    RewriteCond %{HTTP_HOST} ^mywebsite\.co\.uk [NC]
    RewriteRule ^(.*)$ https://www.mywebsite.co.uk/$1 [L,R=301]
    or non-www versions like this;
    Code:
    RewriteCond %{HTTP_HOST} ^www\.mywebsite\.co\.uk$ [NC]
    RewriteRule ^(.*)$ https://mywebsite.co.uk/$1 [L,R=301]
    Whichever you choose should go before any individual 301 redirects, and immediately after RewriteEngine On

    Pick which you prefer but you might need to check exact syntax with your web host - they could have their own recommendations in their FAQs

    This method will cut out the need for duplicate individual www or non-www 301 redirect lines (this is a global redirect)
    Last edited by Beverleyh; 05-17-2016 at 06:01 AM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  9. The Following 2 Users Say Thank You to Beverleyh For This Useful Post:

    gwmbox (05-17-2016),jscheuer1 (05-23-2016)

  10. #7
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default

    Thanks guys, I had the with or without www working ok as well as from http to https. Now with adding the full url to the second part (new url) it seems to be working as best it can

    Thanks again for your help
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

Similar Threads

  1. About Htaccess Redirect
    By round in forum PHP
    Replies: 15
    Last Post: 01-21-2013, 06:06 AM
  2. Resolved .htaccess redirect
    By james438 in forum PHP
    Replies: 7
    Last Post: 01-07-2012, 03:14 PM
  3. .htaccess 301 redirect
    By chetanmadaan in forum Other
    Replies: 4
    Last Post: 08-06-2010, 04:03 AM
  4. .htaccess Redirect
    By tomyknoker in forum Other
    Replies: 4
    Last Post: 04-29-2008, 12:48 AM
  5. Replies: 3
    Last Post: 12-18-2005, 04:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •