[英]Using Url Parameters in Rewrite Rule
好吧,我試圖用通配符創建一個臨時重定向:
http://www.example.com/index.php?topic=1578.0
至http://www.example.com/demo/showthread.php/1578
這是我的htaccess:
RewriteEngine on
RewriteBase /
# Rules for topics:
RewriteRule ^index.php\?topic=([0-9\.0]+)$ /demo/showthread.php/$1
# Rule for homepage
RewriteRule ^index.php$ /demo/forum.php
我的問題是主題規則。 只是它不會重定向。 你能指導我正確的方向嗎?
查詢字符串不能直接在RewriteRule中匹配。
使用此代替:
RewriteCond %{QUERY_STRING} topic=([^&\s]+)
RewriteRule ^index.php /demo/showthread.php/%1? [L,R]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.