I need to change domains when i have a certain path on the url request. More specifically i need to identify first if a certain path (/path) exists on the url request. If exists then show the website with the domain www.mynewdomain.com/path/. If /path does not exists on the url request then show www.myolddomain.com or whatever the request will be.
Asked
Active
Viewed 432 times
0
-
Do you want to keep the parameters to that request as is? I mean let us say, you access using http://www.myolddomain.com/resource/path?query=sachin, do you want to redirect it as http://www.mynewdomain.com?query=sachin – Sandeep Sukhija Apr 06 '16 at 15:11
1 Answers
0
You can use RewriteRule to redirect the request to the new domain. You can mention the config in the virtual host.
RewriteEngine On
RewriteRule /path(.*) http://www.mynewdomain.com/$1 [L,R]
This configuration retains the URL part after the /path
token [ denoted by (.*)
] and is rewritten to the redirected path using $1
.

Sandeep Sukhija
- 1,156
- 16
- 30