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

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.

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>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.