Jump to content

Redirecting non existing subdomains to root domains


watsmyname

Recommended Posts

Well

i have tried searching my problem but couldnt find, so i m posting it. I want to redirect non existing subdomain to the root domain. But if the subdomain exist then it goes to subdomain. like the subdomain http://mysub.mysite.com doesnot exist so if user enters this url in the browser i want to redirect them to http://www.mysite.com via htaccess. How can i achieve this??

 

Thanks

Watsmyname

Link to comment
Share on other sites

Well

i have tried searching my problem but couldnt find, so i m posting it. I want to redirect non existing subdomain to the root domain. But if the subdomain exist then it goes to subdomain. like the subdomain http://mysub.mysite.com doesnot exist so if user enters this url in the browser i want to redirect them to http://www.mysite.com via htaccess. How can i achieve this??

 

Thanks

Watsmyname

 

Currently non existing domain gets redirected to defaultwebpage.cgi.

Link to comment
Share on other sites

If you only have a finite number of subdomains you could do this using mod_rewrite.

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www|mysub)\.mysite\.com
RewriteRule .* http://www.mysite.com%{REQUEST_URI} [R=301]
</IfModule>

Link to comment
Share on other sites

If you only have a finite number of subdomains you could do this using mod_rewrite.

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www|mysub)\.mysite\.com
RewriteRule .* http://www.mysite.com%{REQUEST_URI} [R=301]
</IfModule>

 

Thanks a lot, but this doesnot work. Everytime i type http://mysub.mysite.com the page is redirected to 

http://mysub.mysite.com /cgi-sys/defaultwebpage.cgi

 

I dont know how to prevent to redirect to defaultwebpage.cgi. Couln't trace out it the code to redirect in httpd.conf file as well.

 

Thanks again

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.