Reputation: 767
I have the following virtual host configuration:
<VirtualHost *:80>
ServerName www.something.com
ServerAlias something1.com
Include conf/vhost/www.something.com-rewrites.conf
</VirtualHost>
Under the www.something.com-rewrites.conf file:
RewriteRule ^/apps/(.*)$ / [R=301,L,E=cache_redirect:1]
If there is a request for something1.com/apps/
, I see that the redirect is happening but the URL is getting changed to www.something.com
I don't understand this strange behavior and also is their any other way that I can prevent this behavior?
Upvotes: 0
Views: 691
Reputation: 171
Set the UseCanonicalName value to Yes/On for the virtual host - that will use the ServerName value in the 301s generated by mod_dir. Add origin.
as a ServerAlias
https://httpd.apache.org/docs/current/mod/core.html#usecanonicalname
Upvotes: 0
Reputation: 6727
If your site is running a CMS like wordpress, it uses the domain it was installed on as the Main domain and will redirect to that Main domain regardless of whatever your ServerAlias and ServerMain settings are.
Upvotes: 0
Reputation: 17896
Sound like you have a non-default value for UseCanonicalName OR your client is HTTP/1.0 and not sending a Host: header.
Upvotes: 0