This is my apache configuration (most interesting part of it):
<VirtualHost *:80>
ServerName example.com
...
</VirtualHost>
Works fine and my server properly responds to example.com:80
HTTP requests. Now I'm going to add an alias to this domain. I want all requests to my-new-domain.com:80/test
produce the same responses as to example.com
, for example:
my-new-domain.com/test/xyz -> example.com/xyz
What is important, I don't want to see HTTP redirections (301 code). I want to hide example.com
URL from a user. All that he has to see is my-new-domain.com/test
URL.
put
inside the VirtualHost section
for the rewrite
Use mod_rewrite with mod_proxy (https://httpd.apache.org/docs/2.2/mod/mod_rewrite.html). Otherwise, if domains differ, mod_rewrite performs an external rewrite even if both are served from the same host.
Something like
Another solution would be to create a symlink
test
in my-new-domain.com’s root dir to the root dir of example.com.