Redirect domain to given server folder via htaccess

0

I have two domains that point to my server, both for the public_html root folder. I need each domain to access a particular folder.

Example:

www.dominio1.com.br points to the folder / domain_1

www.dominio2.com.br points to the folder / domain_2

I looked for the commands to use in htaccess but to no avail. I do not understand much of regular expression, does anyone there have the morning?

Thank you in advance.

    
asked by anonymous 12.06.2017 / 16:14

1 answer

2

To perform this task, you must use the RewriteCond

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} .*dominio1.* [NC]
    RewriteRule ^(.*)$ dominio1.php [L]

    RewriteCond %{HTTP_HOST} .*dominio2.* [NC]
    RewriteRule ^(.*)$ dominio2.php [L]
</IfModule>

Explanation

  • RewriteCond %{HTTP_HOST} - Says you check something in the domain
  • .*dominio1.* - Checking if the domain has the
  • [NC] - No case - Want to say it's case insensitive.

If the statement is confirmed, similar to a if it performs the RewriteRule that is below.

    
16.06.2017 / 14:29