![](/img/trans.png)
[英]Redirecting folder from one domain to another using .htaccess 301 redirect
[英]Using .htaccess to redirect from one folder to another, if domain matches
我需要将所有URL从一个文件夹重写到另一个文件夹,但前提是它们正在从某个域发出请求。
所以:
www.example.com/blog/path/to/article
需要去:
www.example.com/new-blog/path/to/article
但这必须以example.com为条件,因为如果请求通过,请说:
www.otherdomain.com/blog/path/to/article
它不需要重定向到新文件夹。
文件夹“ blog”和“ new-blog”都包含两个单独的Wordpress安装。 这是我当前在根公用文件夹中的代码,什么不起作用:
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^blog(.*) /new-blog$1 [L,R]
任何帮助表示赞赏。 谢谢。
我能够使它与此指令一起使用,并实际上放在/ blog文件夹中:
RewriteCond %{HTTP_HOST} ^new\.example\.com$ [NC]
RewriteRule (.*) http://new.example.com/our-happy-place/$1 [L,R]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.