簡體   English   中英

htaccess將動態URL重定向到另一個動態URL

[英]htaccess redirect dynamic URL to another dynamic URL

我需要將一個動態URL重定向到另一個,但參數稍有變化。 這是原始網址:

http://www.EXAMPLE.com/index.php?main_page=index&cPath=5

它需要重定向到

http://www.EXAMPLE.com/index.php?main_page=index&cPath=25

我嘗試了許多不同的變體,但似乎沒有一個奏效。

RewriteCond %{QUERY_STRING} ^main_page=index&cPath=5$
RewriteRule ^/(index\.php|)$ http://www.EXAMPLE.com/index.php?main_page=index&cPath=25 [L,R=301]

我為此感到瘋狂……有人能指出我正確的方向並告訴我我做錯了什么嗎?

我相信斜杠是您的模式中的問題。 在您的根.htaccess中嘗試以下規則:

RewriteCond %{QUERY_STRING} ^main_page=index&cPath=5$ [NC]
RewriteRule ^/?(index\.php)?$ /$1?main_page=index&cPath=25 [NC,L,R=301]

也許沒有條件?

RewriteEngine on
rewriterule ^index.php?main_page=index&cPath=5$ http://www.EXAMPLE.com/index.php?main_page=index&cPath=25 [r=301,nc]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM