![](/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.