[英]Redirect domain based on regular expression
I need to change domains when i have a certain path on the url request. 当我在url请求上有特定路径时,我需要更改域。 More specifically i need to identify first if a certain path (/path) exists on the url request.
更具体地说,我需要首先确定url请求中是否存在某个路径(/ path)。 If exists then show the website with the domain www.mynewdomain.com/path/.
如果存在,则显示域名为www.mynewdomain.com/path/的网站。 If /path does not exists on the url request then show www.myolddomain.com or whatever the request will be.
如果url请求中不存在/ path,则显示www.myolddomain.com或任何请求。
You can use RewriteRule to redirect the request to the new domain. 您可以使用RewriteRule将请求重定向到新域。 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
. 此配置保留
/path
令牌[[ (.*)
表示]之后的URL部分,并使用$1
将其重写为重定向的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.