Results 1 to 6 of 6

Thread: Domain Redirect

  1. #1
    Join Date
    Mar 2004
    Posts
    999

    Domain Redirect

    I'm on a Fedora Core box with cPanel.

    Want to redirect users from: http://domain.com
    To : http://www.domain.com

    I know, its doesn't make too much difference, but since we run an intensive java application on it, cookies don't work well without "www" in the domain.

    Any help greatly appreciated. Thanks.

  2. #2
    Join Date
    Jan 2005
    Posts
    445
    Try this with .htaccess

    rewriteEngine on
    rewriteCond %{HTTP_HOST} ^example\.com
    rewriteRule (.*) http://www.example.com/$1 [R=301,L]

    This will change the urls to the www and send a 301 permanent redirect to keep the spiders happy.

  3. #3
    Join Date
    Mar 2004
    Posts
    999
    Doesn't seem to work.

    My .htaccess is located in /home/account/ (should it be in "public_html"?)

    All it has is the following:

    Code:
    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>
    
    rewriteEngine on
    rewriteCond %{HTTP_HOST} ^example\.com
    rewriteRule (.*) http://www.example.com/$1 [R=301,L]
    btw, whats that http://www.domain.com/$1 for?

  4. #4
    Join Date
    Jan 2005
    Posts
    445
    It's a wildcard for any directory/page after the domain,

    eg. example.com/index.php would become www.example.com/index.php

    the .htaccess should be in the root of the folder for your site, if your site loads from a sub-directory (/subfolder/index.html) then you should add:

    RewriteBase /#this being the name of your sub-directory

    so if your site loads from the sub-directory "subfolder" it would look like this:

    RewriteBase /subfolder

    Chances are you should be fine with RewriteBase /

  5. #5
    Join Date
    Mar 2004
    Posts
    999
    Oh ok.

    This worked for me though:

    Code:
    rewriteEngine on
    rewriteCond %{HTTP_HOST} ^example\.com
    rewriteRule (.*) http://www.example.com [R=301,L]
    Thanks heaps!

  6. #6
    Join Date
    Jan 2005
    Posts
    445
    Anytime!


Posting Permissions

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