SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess question

    Here's the deal...

    I'm hosting two different sites with one host and I have my .htaccess file setup like this:

    Code:
    Options +FollowSymlinks
    
    RewriteEngine On
    RewriteBase /
    
    # These lines prevent unwanted host name change for the URL without trailing slash
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^/*([^/\.]+\.[^/]+/)?(.*[^/])$ http://%{HTTP_HOST}/$2/ [R=301,L]
    
    # your second domain name 
    RewriteCond %{HTTP_HOST} mysite1.com$
    RewriteCond %{REQUEST_URI} !mysite1/
    RewriteRule ^(.*)$ mysite1/$1 [L] 
    
    # your new third domain name 
    RewriteCond %{HTTP_HOST} mysite2.com$
    RewriteCond %{REQUEST_URI} !mysite2/
    RewriteRule ^(.*)$ mysite2/$1 [L]
    FYI - Each site sits in a separate directory (ex: htdocs/mysite1 and htdocs/mysite2). I need to know how to force "www." before the domain so that when people go to "mysite1.com" it'll switch to "www.mysite1.com." The other thing I need is to prevent the directory that the site is in from showing up in the URL. For instance, if someone were to just type in "mysite1.com/content" to their browser, it would change to "mysite1.com/content/content/."

    Thank you and let me know if you need any more info.

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    From the SEO FAQ you can force the www with this:

    Code:
    RewriteEngine On
      RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
      RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    I'm not sure about the second one, though you may be able to work it out with this same code.

    Hope it helps

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Johnny Gulag
    From the SEO FAQ you can force the www with this:

    Code:
    RewriteEngine On
      RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
      RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    I'm not sure about the second one, though you may be able to work it out with this same code.

    Hope it helps
    Thanks. I tried using that but it just redirected me to the directory above where my two sites are located (htdocs/). I tried various different things to fix it, any suggestions?


Bookmarks

Posting Permissions

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