is this an .htaccess issue?

Discussion in 'Apache' started by Joobz, Jan 24, 2008.

  1. #1
    I have two domains and each are on the same server, have the same type of script running on each domain and have the same values in their .htaccess files.

    the first site's domain is in this structure:
    http://www.domain.com
    Code (markup):
    the second one is this way:
    http://domain.com
    Code (markup):
    I can't get it to add the www before the domain. The first domain has traffic while the second one has none. Can this be related somehow? How do I get the second one to display with "www"?

    Even when I add www, the relative links appear without it when you hover over them.
     
    Joobz, Jan 24, 2008 IP
  2. norbert

    norbert Guest

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could use mod_rewrite to redirect all traffic to www
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #redirect domain.xyz to [url]www.domain.xyz[/url]
    RewriteCond %{HTTP_HOST} ^domain\.xyz$ [NC]
    RewriteRule ^(.*)$ http://www.domain.xyz/$1 [R=301,L]
    </IfModule>
    
    Code (markup):
    If mod_rewrite is loaded and you place this code in your .htaccess file all requests are redirected to www
     
    norbert, Jan 25, 2008 IP
  3. Joobz

    Joobz Peon

    Messages:
    598
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, but every second level link would still go back to

    http://domain.com/subdirectory
    Code (markup):
    Wouldn't it? I guess I'm just wondering how it could do what it's doing without me setting it up that way.
     
    Joobz, Jan 25, 2008 IP
  4. norbert

    norbert Guest

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe I haven't understood your situation completely.
    But with the code I posted requests without www are
    no longer possible, all get redirected. If this is not what
    you mean please make an example for "every second
    level link would still go back to ...".
     
    norbert, Jan 25, 2008 IP
  5. Joobz

    Joobz Peon

    Messages:
    598
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Oh, maybe I didn't understand you completely. I will try that. Thank you.
     
    Joobz, Jan 25, 2008 IP