[英].htaccess 301 redirect conflicting with rewriterule
我正在嘗試重定向URL,但是它與rewrite-rule沖突,我正在使用此重定向規則
Redirect 301 /antique-vintage-rugs/170-antique-oriental-rugs-carpets https://example.com/antique-vintage-rugs/170-antique-rugs
它帶我到此鏈接https://example.com/antique-vintage-rugs/170-antique-rugs?action=clear&template=170-antique-oriental-rugs-carpets而不是此https://example.com/仿古復古地毯/ 170-古董地毯
我的重寫URL是這個
RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^antique-vintage-rugs/(.+) results.php?action=clear&template=$1 [NC]
有什么方法可以獲取所需的輸出重定向鏈接?
您只需要在此處使用mod_rewrite,而不要將其與mod_alias( Redirect
指令所屬的地方)混合使用。 當您將兩者混合使用時,兩者最終都會處理相同的請求。
因此,使用以下命令代替Redirect
:
RewriteRule ^antique-vintage-rugs/170-antique-oriental-rugs-carpets https://example.com/antique-vintage-rugs/170-antique-rugs [L,R=301]
但請確保它在您的其他規則之前 。
我有一個類似的問題。 當我已經在.htaccess文件中編寫了一些重寫規則時,我試圖添加來自cpanel的重定向。 我得到的錯誤是“沒有任何標記”,最終我要做的是保留了現有規則的副本並清理了.htaccess。 然后去添加了我從cpanel所需的所有重定向,最后在文件末尾放回了我自己的重寫規則。 那對我有用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.