我在使用.htaccess文件中的mod_rewrite重定向到另一個域時遇到了問題。mod_rewrite:確切的URL不匹配,但匹配不確切
這是我有:
RewriteCond %{HTTP_HOST} ^www.somedomain.com/events_detail/an-event [NC]
RewriteRule ^(.*)$ http://otherdomain.com/directory/8559 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^www.somedomain.com [NC]
RewriteRule ^(.*)$ http://otherdomain.com/directory [L,R=301,NC]
出於某種原因www.somedomain.com/events_detail/an-event
我重定向到http://otherdomain.com/directory
而不是http://otherdomain.com/directory/8559
當測試了我的一個測試的.htaccess,它表明,它不匹配第一個條件,但匹配第二個。我試圖刪除L選項,取消前進^沒有成功。
謝謝
使用%{REQUEST_URI}匹配url中的路徑名。 – starkeen