301 Redirect Not Working as I Expect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • condemnity
    Junior Member
    • Dec 2004
    • 22

    301 Redirect Not Working as I Expect

    I have a redirect from mydomain.com to http://www.mydomain.org. It's permanent and wildcard. Yet, the only time I see a redirect is if I go to mydoman.com or www.mydoman.com. The browser is properly redirected to http://www.mydomain.org.

    When I go to mydomain.com/file_name, it correctly serves the file from the .org account. But the browser remains and the .com and doesn't get redirected.

    I see two possible answers here: 1) I'm doing it wrong or 2) I'm misunderstanding how a redirect works. I'm guessing for number 1. Thoughts?

    Thanks!
    Mike
    NYC Caterers by Epicurean Creations
  • AndrewT
    Administrator
    • Mar 2004
    • 3653

    #2
    It sounds like you're just missing an aspect to redirect any mydomain.com request (instead of just /) to mydomain.org. This can be setup in the redirects section of cPanel. If you need help with this just submit a ticket and we can take a look.

    Comment

    • djn
      Senior Member
      • Mar 2004
      • 140

      #3
      Putting this into the .htaccess file in the site root should do the trick:

      Code:
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$
      RewriteRule ^(.*) http://mydomain.org/$1 [NC,L,R=301]

      Comment

      • condemnity
        Junior Member
        • Dec 2004
        • 22

        #4
        You sir, are correct! Here's what I ended up with at the beginning of my .htaccess:

        IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

        # BEGIN redirect root to www
        # <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^mikegulbin.com$ [NC]
        RewriteRule ^(.*)$ http://www.mikegulbin.com/$1 [R=301,L]
        # </IfModule>
        The other important thing to mention is that Andrew said he had to put it at the beginning, BEFORE the stuff that WordPress inserts when it gets installed.
        NYC Caterers by Epicurean Creations

        Comment

        Working...