1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

redirect via mod_rewrite .htaccess help needed

Discussion in 'General Scripting Chat' started by monchichi, May 19, 2012.

  1. monchichi

    monchichi Power Member

    Joined:
    Jun 3, 2011
    Messages:
    591
    Likes Received:
    248
    Occupation:
    BOSS.
    Location:
    173.194.35.147
    hey guys,

    I have set up a hosting which includes 2 domains but the second only as a domain alias. So I need to "split" those domains by htaccess mod:rewrite.

    This is what I put into the htaccess:

    Code:
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST}   ^(www\.)?domainname.com
    RewriteCond %{REQUEST_URI} !^/innerfolder
    RewriteRule ^(.*)$ innerfolder/$1 [L]
    
    so far so good. It works but in the adress field of the browser it shows domainname.com/innerfolder/ and I want it to show domainname.com only. How can I get that right?
     
  2. monchichi

    monchichi Power Member

    Joined:
    Jun 3, 2011
    Messages:
    591
    Likes Received:
    248
    Occupation:
    BOSS.
    Location:
    173.194.35.147
    Fixed it myself. For anybody interested, it works with this code:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domainname\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.domainname\.com$
    RewriteCond %{REQUEST_URI} !^/innerfolder/
    RewriteRule (.*) /innerfolder/$1 [L]