Redirect page/subfolder to new domain url without changing url in browser

5,633

Proxy Pass might be what you are looking for. It will use the url that they connected to, and act as a proxy to the new url. They will still see the old url.

ProxyVia on
ProxyRequests Off
ProxyPreserveHost Off

ProxyPass /test http://newdomain/test
ProxyPassReverse /test http://newdomain/test
Share:
5,633

Related videos on Youtube

testmaster
Author by

testmaster

Updated on September 18, 2022

Comments

  • testmaster
    testmaster over 1 year

    I have been looking for an answer this without any luck (searched everywhere)

    Basically, I want to rewrite a page (subfolder) to a new domain without changing the url.

    I've tried with no luck:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/test/
    RewriteRule ^(.*) http://newdomain/$1 [P] 
    

    I have had a look at the "duplicate" question and it doesn't answer.

    It does not explain how to rewrite a page to a new domain without changing the url.

  • testmaster
    testmaster almost 9 years
    it gives me a 500 server error
  • testmaster
    testmaster almost 9 years
    <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^test/(.*)$ newdomain/$1 [P,L] </IfModule>
  • testmaster
    testmaster almost 9 years
    in addition, i want to point out that /test/ is simple a static page and it's 1 url that needs redirection to a whole new domain without changing the url
  • serverliving.com
    serverliving.com almost 9 years
    I forgot to mention that [P] flag is not allowed in htaccess files. You need to put this rule in the main apache virtual host configuration file.
  • testmaster
    testmaster almost 9 years
    ive got it working but when it redirects to the new domain, the images break as it tries to look for the images on the old domain.