Is there some way to silently, internally, redirect all pages to another server?

I have a site on Site5's server "huckleberry". I can reach the page - with a SSL certificate - via the path to their server [this is common for shared hosts]:

  1. http://mysite.com/checkout.php (insecure)
  2. https://huckleberry.site5.com/~myaccount/mysite.com/checkout.php (secure)

All of the page's links and whatnot assume the first domain, and editing all of the pages is not practical.
Eg. a link to /Assets/mystyles.css 404's out terribly.

Is there some way that users can log onto the second domain, and Apache will treat all requests as if they are pointing to the first page?

So that when the page requests /mystyles it will get mysite.com/mystyles.css instead of huckleberry.site5.com/~myaccount/styles.css?

I have tried to figure out using ProxyPass and mod_rewrite, but can't get it to work.


  • Apache doesn't control the content generated by your PHP. You'll need to account for the different access points within your PHP code and the HTML that it generates. And relative paths are your friend. – Shane Madden Oct 27 '11 at 21:20

Why do people insist on hard coding links instead of using relative paths?

There are products which will do a bulk find and replace in a folder which would be more of a maintainable long term solution.

  • It would be, if I didnt hard code the links on purpose. However, the setup it shares with the testing server requires hard links – SamGoody Oct 27 '11 at 21:24

In the 2nd domain (hucklebery.site5.com) you can setup in your host config file (not .htaccess):

ProxyPassMatch ^/~myaccount/mysite.com/(.*)$ http://mysite.com/$1
# You may also need to do this to deal with cookies
ProxyPassReverseCookieDomain mysite.com hucklebery.site5.com
ProxyPassReverseCookiePath / /~myaccount/mysite.com/
  • The two domains are the same location on the server - I really only have one folder. But I do not know how I would edit the host config file - the shared hosting alows .htaccess but not editing any server files – SamGoody Oct 27 '11 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.