Apache Virtual Host redirect just for servername

209 views Asked by At

I have a virtual server, which supports just subdomains of our company. We're using Apache, and I have virtual hosts set up to serve each of these subdomains. People on our network can reach the website of these subdomains by using just the name in DNS, such as just typing ABC into the URL of a browser, rather than typing ABC.XYZ.com.

My Virtual host handles the ABC.XYZ.com entries fine, and I've set up a virtual host that has ServerName: abc.xyz.com and then ServerAlias: abc.

The problem comes in with some of our PHP scripting and redirects, where because it comes through as just "abc", it needs to be coming through as "abc.xyz.com" for some things to resolve properly for us.

Is there a way either in a .htaccess, mod-rewrite, or virtualhost to force "abc" to be redirected to "abc.xyz.com" ?

1

There are 1 answers

0
umka On BEST ANSWER

This rule should work for you

RewriteEngine on
RewriteCond %{HTTP_HOST} =abc
RewriteRule ^(.*)$ http://abc.xyz.com/$1 [R,L]