Php 永久重定向htaccess到一个新域名,保持URL的一部分不变
我从来没有写过任何htaccess密码,默认情况下,这个密码没有给我足够的时间来获得我所需要的 我有一个类似于:Php 永久重定向htaccess到一个新域名,保持URL的一部分不变,php,.htaccess,redirect,iis,Php,.htaccess,Redirect,Iis,我从来没有写过任何htaccess密码,默认情况下,这个密码没有给我足够的时间来获得我所需要的 我有一个类似于:http://domaineA.com/target:/to/be/removed/keep/this.ext 我想将所有像这样的URL重定向到: http://domaineB.com/keep/this.ext 我试过了,但没有成功: //301 Redirect Entire Directory RedirectMatch 301 http://domaineA.com/targ
http://domaineA.com/target:/to/be/removed/keep/this.ext
我想将所有像这样的URL重定向到:
http://domaineB.com/keep/this.ext
我试过了,但没有成功:
//301 Redirect Entire Directory
RedirectMatch 301 http://domaineA.com/target:/to/be/removed(.*) http://domaineB.com/$1
更新:
我忘了提到/keep/this.ext是动态的,它代表我的目录中的所有文件
谢谢您可以将其放入您的.htacces或虚拟主机中,如下所示
Redirect permanent http://domaineA.com/target:/to/be/removed/keep/this.ext http://domaineB.com/keep/this.ext
您可以将此规则用作站点根目录中的第一条规则。htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?domaineA\.com$ [NC]
RewriteRule ^/?target:/to/be/removed(/.*)?$ http://domaineB.com$1 [L,NE,R=301,NC]
哦,对不起,我没有提到它涉及许多文件,所以它必须是动态的,因为keep/this.ext是动态的。我会更新我的帖子。