Jump to content

Redirect All subdomain url to specific url using .htaccess


biswarup

Recommended Posts

(anything).example.com/(anything) to example.com/(anything)

 

for example :

 

img1.example.com/test1.jpg to example.com/test1.jpg

 

img105.example.com/anotherimage.png to example.com/anotherimage.png

 

tdr.example.com/a.css to example.com/a.css

First you need to set-up wildcard subdomains on your DNS. Assuming this is done, something like this should work...

 

RewriteCond %{HTTP_HOST} !example.com

RewriteRule .* http://example.com/%{REQUEST_URI} [R=302]

 

Once you're happy it's working you can switch the 302 to 301.

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.