.htaccess affects subfolder

Discussion in 'Apache' started by azamo, Feb 20, 2008.

  1. #1
    PROBLEM SOLVED

    I have my main domain - http://improvefirefox.com - hosted at site5.com. So it is in
    public_html/
    Code (markup):
    I have another domain - http://anitawielgosz.com - set up as a domain pointer and its files are in
    public_html/anitawielgosz/
    Code (markup):
    subfolder.

    I would like them to run independently. But when I open http://anitawielgosz.com, I get reirected to it's subfolder: http://improvefirefox.com/anitawielgosz/. I do not want this to happen. I guess the reason is the .htaccess file which I created for the main domain only (public_html/.htaccess):


    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    
    # eliminate www
    RewriteCond ${HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^improvefirefox\.com
    RewriteRule (.*) http://improvefirefox.com/$1 [L,R=301]
    
    # trailing slash
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule (.*) http://improvefirefox.com/$1/ [L,R=301]
    
    # added by wordpress
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L] 
    Code (markup):
    What's wrong and needs to be changed in order to get both domains work properly? Can somebody help me, please?


    ----------------------------
    SOLUTION
    I excluded folders from .htacces, changing it to:
    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    
    # eliminate www
    RewriteCond ${HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^improvefirefox\.com
    RewriteRule !^(anitawielgosz|test)(.*)?$ http://improvefirefox.com/$1 [L,R=301]
    
    # trailing slash
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule !^(anitawielgosz|test)(.*)?$ http://improvefirefox.com/$1/ [L,R=301]
    
    # wordpress
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule !^(anitawielgosz|test)(.)?$ /index.php [L]
    Code (markup):
     
    azamo, Feb 20, 2008 IP
  2. Cybernaut

    Cybernaut Peon

    Messages:
    408
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is a workaround rather than a true solution, in my opinion. Every time you add a new domain, you will have to edit htaccess file. The solution to check whether we are in our top level primary domain or not. If, not then just abort rewriting. This simple RewriteCond before every Rewrite block will do it properly.

    RewriteCond %{HTTP_HOST} ^(www\.)?improvefirefox\.com$
    Code (markup):
    Cybernaut.
     
    Cybernaut, Feb 22, 2008 IP