Web Analytics Made Easy -
StatCounter 301 Redirect Problems - CodingForum

Announcement

Collapse
No announcement yet.

301 Redirect Problems

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎