Balderick Posted October 28, 2016 Share Posted October 28, 2016 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 More sharing options...
justsomeguy Posted October 28, 2016 Share Posted October 28, 2016 I think you would only be able to do that if you have subdomains mapping to specific directories, and you can use htaccess to check if the directory exists. Link to comment Share on other sites More sharing options...
Balderick Posted October 29, 2016 Author Share Posted October 29, 2016 I have one page in one directory. The subdomain is exploded from the http address and fetches the required data. I think it's unnecessary extended to make multiple directories. Is it the only solution? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 31, 2016 Share Posted October 31, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now