![](/img/trans.png)
[英]Redirect all urls with parameters from old domain to new except one url
[英]How to Redirect All urls to a new domain in apache, except one
我需要將一個站點上的所有內容重定向到一個新域,但一條路徑除外。
所以 domain.com/anything 需要 go 到 newdomain.com/anything。
但我不希望 domain.com/services/xml 重定向。
我嘗試了很多條件,但沒有任何效果。 它總是最終重定向它,或者將它重定向到新域上的其他一些奇怪的路徑。
這不起作用:
RewriteCond %{REQUEST_URI} !^/services/xml$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
任何幫助表示贊賞。 謝謝。
多虧了我的談話 Ansari 和托管公司的一些幫助,我想通了。 問題似乎是 url 被重寫為 index.php,然后又被重定向。 所以:
RewriteCond %{REQUEST_URI} !^/services/xmlrpc
RewriteCond %{REQUEST_URI} !index\.php$ [NC]
RewriteRule ^(.*)$ http://www.wikiweightscore.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [QSA]
這適用於我想要的確切用例。
那么試試這個:
RewriteCond %{REQUEST_URI} !^/services/xml
RewriteCond %{HTTP_HOST} .*
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
我在遷移到新域時遇到了同樣的問題,但需要保持服務端點在舊域上處於活動狀態,因為它們在外部處於活動狀態。 關鍵是包含 index.php 的 RewriteCond:
RewriteCond %{REQUEST_URI} !^/services/active/endpoint$
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{HTTP_HOST} ^old-domain\.org$ [NC]
RewriteRule ^(.*)$ http%{ENV:protossl}://new-domain/$1 [L,R=301]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.