Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    301 Redirect Problems

    I'm trying to redirect from my non-www homepage to my www homepage. Should be simple, but after dozens of tries, and asking on several forums, including the forum of the website system I use (zen-cart) nothing has of yet worked.

    I've tried every permutation of the redirect I could find.

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.oldewatches\.com
    RewriteRule (.*) http://www.oldewatches.com/$1 [R=301,L]
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.oldewatches\.com
    RewriteRule ^(.*)$ http://www.oldewatches.com/$1 [R=301,L]
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^oldewatches.com [NC]
    RewriteRule (.*) http://www.oldewatches.com/$1 [L,R=301]
    etc.

    Nothing works. What is odd is when I add the code:

    Code:
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
    RewriteRule ^(.*)index\.html$ http://www.oldewatches.com/$1 [R=301,L]
    http://www.oldewatches.com/index.html WILL redirect to http://www.oldewatches.com but if it is http://oldewatches.com/index.html (without www) it will redirect to http://oldewatches.com, also without www.

    I asked another web designer about this and he said even with the redirect on from non-www to www, it won't show up in the browser. He didn't explain why. I know it isn't browser-related since other websites with redirects will redirect properly in my browser (Firefox 3.6)

    What other reasons could there be for this?

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    There's no reason that any of those rules shouldn't work with varying degrees of success. If none of them are working, then it's likely something else in your .htaccess file causing this. Like a RewriteRule that matches before it.

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is other rules in my .htaccess file, and in case it was that, I've already tried removing everything else in the .htaccess and leaving only the redirect codes above. Still nothing.

    Extremely frustrating.

  • #4
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    I can only think of two other things that could cause issues. Firstly HTTP_HOST value not being set, it seems unlikely but you can test easily enough by putting print_r($_SERVER); in a php file and viewing the page. The other guess would be that Zen Cart itself does something with the URL. I've never worked with Zen Cart, but I work with Magento a lot and it has a base url value set in the database that it redirects to. That also seems fairly unlikely though as you seem to indicate it stays on the requested domain, regardless of the re-direct.


  •  

    Posting Permissions

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