Need help with .htaccess file (www. redirection)

Discussion in 'Programming' started by projectwealth, Jan 9, 2008.

  1. #1
    Hello there,

    I'm going completely insane with a new website of mine at the moment.:confused:

    I'm hosting with hostgator.com and they use an apache server. The problem is when I type my website name into the browser http://www.richandjobless.com for some reason it redirects to http://richandjobless.com

    For branding reasons I want to keep the www.

    The default .htaccess file reads as follows:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress


    I've tried to edit the .htaccess file to redirect to www. by adding the following code:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^richandjobless.com
    RewriteRule (.*) http://www.richandjobless.com/$1 [R=301,L]


    but it redirects back to www. then the non-www address in an infinite loop so it doesn't help much at all.:rolleyes:

    Does any one have any ideas why this is happening and what I can do to fix it?

    FYI... I don't know if this helps but the contents of the index.php file that the .htaccess file refers to is as follows:

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>


    Any and all suggestions would be GREATLY appreciated.

    Thanks very much,

    Dave
     
    projectwealth, Jan 9, 2008 IP
  2. jmf000

    jmf000 Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The problem cant be solved via modding .htaccess.
    Your pages generated by php return redirect code.
    You have to dig wp-blog-header.php and find line like (may be after check for www prefix)
    
    header('Location: ....');
    
    Code (markup):
    It causes redirection.
     
    jmf000, Jan 9, 2008 IP
  3. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Check your WordPress admin panel. Go to "Options", then "General" and look at : WordPress address (URL) and Blog address (URL). I suspect that the problem is in one of these parameters.

    Jean-Luc
     
    Jean-Luc, Jan 9, 2008 IP
    sudarshannus likes this.
  4. projectwealth

    projectwealth Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    JEAN LUC!!!!!!!!!!!!!!!!! BUDDY!!!!!!!!! DO YOU KNOW HOW MUCH I LOVE YOU!!! :)

    That worked a treat! I'm not familiar with wordpress settings at all and just presumed it was the .htaccess file!

    YOU ARE A LEGEND MY FRIEND!

    Thanks again,

    Dave


    PS:Thanks for your suggestion too jmf000!
     
    projectwealth, Jan 9, 2008 IP