Mobile app version of vmapp.org
Login or Join
Chiappetta492

: 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

@Chiappetta492

Posted in: #Htaccess #ModProxy

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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Chiappetta492

1 Comments

Sorted by latest first Latest Oldest Best

 

@Merenda212

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]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme