2012-03-21 211 views
1

我應該寫什麼規則htaccess的重定向使重定向規則htaccess的

http://abc.com/http://xyz.com/path/重定向到http://xyz.com/path/

http://abc.com/?url=http://xyz.com/path/不應重定向

感謝, Loveleen

回答

0

重要的是要記住這種redir ection是Apache在RewriteRule匹配中刪除了所有多個斜線。出於這個原因,最好使用變量%{THE_REQUEST},它保持「原樣」。因此,只需在您的.htaccess DOCUMENT_ROOT目錄下使用此代碼:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(https?://[^\s]+) [NC] 
RewriteRule^%1 [L,R]