0

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.

1

2 Answers 2

1

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
0

RewriteEngine On RewriteBase / RewriteRule ^test/(.*)$ http://newdomain/$1 [P,L]

the above rule will redirect all /test/... to backend without modifying the browser URL

5
  • it gives me a 500 server error
    – testmaster
    May 14, 2015 at 10:13
  • <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^test/(.*)$ newdomain/$1 [P,L] </IfModule>
    – testmaster
    May 14, 2015 at 10:15
  • 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
    – testmaster
    May 14, 2015 at 10:17
  • 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. May 14, 2015 at 11:23
  • 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.
    – testmaster
    May 14, 2015 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .