The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Simple redirect not working...

Discussion in 'General Discussion' started by 4u123, Sep 6, 2007.

  1. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
  2. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    Could anyone spare a minute to offer some advice ? The redirect looks fine to me but just doesnt work.
     
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,447
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
  5. NexGenUK

    NexGenUK Active Member

    Joined:
    May 7, 2004
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    6
    Its actually due to apache being difficult - if you are redirecting to a directory, apache will force another redirection to ensure there is a trailing "/" to the folder:
    eg if i visit:
    http://www.randomdomainusingapache.com/folder
    apache will redirect it to the ServerName /folder/
    in this instance it would redirect to http://randomdomainusingapache.com/folder/

    this is due to the fact that www.{domain} is setup as an alias and the plain old domain is setup as the ServerName:

    httpd.conf extract:
    This is not something that cPanel can inherently fix because its apache that is governing this.
     
  6. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    No, its not that but it has something to do with slashes.

    The same issue happens when redirecting to a file....

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.mydomain.com$
    RewriteRule ^(.*)$ http://www.myotherdomain.com/redirect.html [R=301,L]

    In this instance, if you enter the first domain in a browser it simply redirects to myotherdomain.com instead of going to redirect.html

    I notice the redirect DOES work if you enter mydomain.com/ or anything after the forward slash.

    So...

    mydomain.com or www.mydomain.com do not work.
    mydomain.com/ or www.mydomain.com/ does work

    Performing a forced upcp has not fixed this issue. The server is using release build.

    Is there something I need to add in the httpd.conf file to correct this ?

    It seems that the redirect isnt working because apache ISNT automatically adding the slash.
     
    #6 4u123, Sep 17, 2007
    Last edited: Sep 17, 2007
  7. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    Here is another example...

    This customer has two accounts with us.

    On an older server, this mod_rewrite directive works fine - on one of the new ones it doesnt. Bear in mind that we have not made any changes to the apache configuration on either of these servers - they are standard Cpanel release build servers - both are running the same build. The only difference is that one is 3 years old, the other is about 3 weeks old.

    RewriteRule ^categories/([^/.]+).html?$ index.php?category=$1 [L]

    This rule takes a page named for example weddings.html and re-writes it to index.php?category=weddings


    On the new server it just attempts to go to weddings.html which doesnt exists so a 404 is produced. Its as though the htaccess file is being ignored.
     
  8. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    Anyone have any ideas before I log a ticket with cpanel ?
     
  9. sabarishks

    sabarishks Active Member

    Joined:
    Jun 29, 2007
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    .htaccess to .htaccess.bak

    Please try moving .htaccess to .htaccess.bak.........

    Just a try to narrow down the issue.
     
Loading...

Share This Page