1
I am trying to do a subdomain redirect on . 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 http://testephp.com.br works right, everything ok, however, when typing something similar to http://xpto.testephp.com.br I am not redirected to anywhere, only get error: ERR_NAME_NOT_RESOLVED.
I’m using shaman on my local machine.
My vhost is like this:
<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot "D:/xampp/htdocs/testephp"
 ServerName testephp.com.br
 ServerAlias *.testephp.com.br
 <directory "D:/xampp/htdocs/testephp">
 AllowOverride All
 Order Allow,Deny
 Allow from all
 Require all granted
 </directory>
</VirtualHost>
– Márlon Etiene
As far as I know, it is not possible to use a wildcard on
ServerAlias
. You must discriminate between the subdomains one by one.– Rodrigo Rigotti
I understand, but how do I then have dynamic subdomains?
– Márlon Etiene
I searched and it seems that it is possible. Check out this tutorial: http://blog.calcatraz.com/wildcard-subdomains-in-apache-1422
– Rodrigo Rigotti
Thanks friend but I could not. I will continue my research and if I get something put here to help others who have the same problem.
– Márlon Etiene