: An equivalent to ProxyPreserveHost in .htaccess? I am moving a website from one shared host to another. The site is all files. I have already copied the files to the new host. I'd like to
I am moving a website from one shared host to another.
The site is all files. I have already copied the files to the new host.
I'd like to redirect all HTTP requests from the old host to the new host, so I can remove the site on the old host and maintain just the copy on the new host, even before the DNS records have been updated to point to the new host.
The old host is running Apache 2.2, so this can be done by adding the following to the VirtualHost section(s) for my site:
ProxyPreserveHost On
ProxyPass / ipaddress.of.my.new.host/
The ProxyPreserveHost directive is required here. It allows the new host to find the files for my site.
Now what if I can't edit these configuration files?
Can the same effect be achieved from an .htaccess file?
Instead of the ProxyPass directive, I have
RewriteRule ^(.*) ipaddress.of.my.new.host/ [P,L]
That works fine. But how to preserve the Host: header?
Adding
Header set Host my.domain.name
has no effect.
(See also this question and this question.)
UPDATE: as w3dk noted below, the directive to set a request header is RequestHeader, not Header, but using
Request set Host my.domain.name
has no effect, either.
More posts by @Chiappetta492
1 Comments
Sorted by latest first Latest Oldest Best
As far as I know the proxy target in mod_rewrite is simply a front-end to mod_proxy and the ProxyPreserveHost is the only directive to configure that behaviour. So without access to the main server config or VirtualHost config your indeed without luck.
You might be lucky and your old hosting provider may already resolve your site to the new ip-address; you could then use the following work-around:
RewriteRule ^(.*) <your_domain_name>/ [P,L]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.