Subdomain redirection in .htaccess

1

I'm trying to do a subdomain redirect in .htaccess as follows:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{HTTP_HOST} !^testephp\.com\.br
RewriteCond %{HTTP_HOST} ([^\.]+)\.testephp\.com\.br$ [NC]
RewriteRule ^/?$ http://testephp.com.br/index2.php [L,QSA]

If I enter the url link works okay, all ok, however, when typing something similar to #

I'm using xampp on my local machine.

    
asked by anonymous 15.01.2015 / 20:18

1 answer

1

This setting you should do in the virtual host configuration for your domain:

ServerName       testephp.com.br
ServerAlias xpto.testephp.com.br

Also, do not forget to edit your hosts file to understand the requests to both domains as requests for 127.0.0.1 .

    
15.01.2015 / 20:19