Jump to content

redirect not existing subdomain to www with htaccess


Balderick

Recommended Posts

I'm looking for directives that help solving the problem of redirecting a not existing subdomain towards the www subdomain.

 

I know/guess .htaccess is used, but cant figure out how.

 

My present situation is that existing subdomains are redirected well.

 

I adjusted virtual hosts in this way:

       <VirtualHost *:80> 
		ServerName mysite.dev
		ServerAlias mysite.dev *.mysite.dev
		DocumentRoot X:/wamp/www/TestVirtHost/
		<Directory  "X:/wamp/www/TestVirtHost/">
			Options +Indexes +FollowSymLinks +MultiViews
			AllowOverride All
			Require local
		</Directory>
	</VirtualHost>

my etc/hosts file has the following rules

     127.0.0.1  *.mysite.dev mysite.dev
     127.0.0.1 subdomain_one.mysite.dev
     127.0.0.1 subdomain_two.mysite.dev

Can some expert explain please what the .htaccess should look like for the problem explained above.

Link to comment
Share on other sites

I don't know. I don't know of any directives in htaccess that can query the server configuration to figure out if a particular subdomain or virtual host is defined in the config files. I do know that there are ways to check if a directory exists.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...