DEK4
DEK4

Reputation: 73

Redirect all sub domain to another domain apache

I want to redirect all sub domains of my webserver sites that start with mail to a https://anotherSub.domain.com

How can i do it?

Put this at the top of the yours default apache config file
RewriteEngine on  
RewriteCond %{HTTP_HOST} ^SUBDOMAIN.* 
RewriteRule ^(.*) YOUR LINK (ex. http://www.google.it)

Upvotes: 1

Views: 991

Answers (1)

Derek
Derek

Reputation: 3435

This code matches any subdomain that starts with mail on domain.com and rewrites it to a https://anothersub.domain.com.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mail(.*?).domain.com [NC]
RewriteRule ^(.*)$ https://anothersub.domain.com/$1 [L, 301]

Upvotes: 1

Related Questions