.htaccess - 如果参数存在,htaccess 覆盖重写规则
问题描述
我的 htaccess 出现问题,其中 URL 中的参数被现有规则覆盖,但我不知道如何修改它。
当我访问 URL/trade/?sold=1
时,它会将其重写为 just /trade/
,这是不需要的,因为参数sold=1
未传递给 PHP,因此页面保持不变。
这是我在 htaccess 中的完整重写部分:
<IfModule mod_rewrite.c>
# You may need to un-comment the following lines
# Options +FollowSymlinks
# To make sure that rewritten dir or file (/|.html) will not load dir.php in case it exist
# Options -MultiViews
# REMEBER YOU ONLY NEED TO STARD MOD REWRITE ONCE
RewriteEngine On
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
# RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
# REWRITE BASE
RewriteBase /
# Zulu fix crumbs ?f= etc. for each forum (currently disabled with pound sign)
#RewriteCond %{QUERY_STRING} (^|&)f=1($|&)
#RewriteRule ^viewforum\.php$ /database? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=2($|&)
#RewriteRule ^viewforum\.php$ /uniques? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=3($|&)
#RewriteRule ^viewforum\.php$ /runewords? [L,R=301]
##RewriteCond %{QUERY_STRING} (^|&)f=4($|&)
#RewriteRule ^viewforum\.php$ /sets? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=5($|&)
#RewriteRule ^viewforum\.php$ /base? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=6($|&)
#RewriteRule ^viewforum\.php$ /recipes? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=7($|&)
#RewriteRule ^viewforum\.php$ /monsters? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=8($|&)
#RewriteRule ^viewforum\.php$ /npcs? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=9($|&)
#RewriteRule ^viewforum\.php$ /skills? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=10($|&)
#RewriteRule ^viewforum\.php$ /zones? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=11($|&)
#RewriteRule ^viewforum\.php$ /quests? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=12($|&)
#RewriteRule ^viewforum\.php$ /misc? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=13($|&)
#RewriteRule ^viewforum\.php$ /tools? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=14($|&)
#RewriteRule ^viewforum\.php$ /builds? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=15($|&)
#RewriteRule ^viewforum\.php$ /articles? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=16($|&)
#RewriteRule ^viewforum\.php$ /trade? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=17($|&)
#RewriteRule ^viewforum\.php$ /forums? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=18($|&)
#RewriteRule ^viewforum\.php$ /feedback? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=21($|&)
#RewriteRule ^viewforum\.php$ /bug-reports? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=23($|&)
#RewriteRule ^viewforum\.php$ /contributions? [L,R=301]
#RewriteCond %{QUERY_STRING} (^|&)f=24($|&)
#RewriteRule ^viewforum\.php$ /price-check? [L,R=301]
# HERE IS A GOOD PLACE TO FORCE CANONICAL DOMAIN
# Define fully qualified ssl aware protocol
# RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
# RewriteRule ^.*$ - [env=HttpFullProto:http%2://]
# RewriteCond %{HTTP_HOST} !^diablo2$ [NC]
# RewriteRule ^(.*)$ %{ENV:HttpFullProto}diablo2/$1 [QSA,L,R=301]
# DO NOT GO FURTHER IF THE REQUESTED FILE / DIR DOES EXISTS
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
# FORUM INDEX REWRITERULE WOULD STAND HERE IF USED. "forum" REQUIRES TO BE SET AS FORUM INDEX
# RewriteRule ^forum\.html$ /index.php [QSA,L,NC]
# FORUM ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/?(page([0-9]+)\.html)?$ /viewforum.php?f=$2&start=$4 [QSA,L,NC]
# TOPIC WITH VIRTUAL FOLDER ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?f=$2&t=$4&start=$6 [QSA,L,NC]
# TOPIC WITHOUT FORUM ID & DELIM ALL MODES
RewriteRule ^([a-z0-9_-]*)/?(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?forum_uri=$1&t=$3&start=$5 [QSA,L,NC]
# PROFILES THROUGH USERNAME
RewriteRule ^member/([^/]+)/?$ /memberlist.php?mode=viewprofile&un=$1 [QSA,L,NC]
# USER MESSAGES THROUGH USERNAME
RewriteRule ^member/([^/]+)/(topics|posts)/?(page([0-9]+)\.html)?$ /search.php?author=$1&sr=$2&start=$4 [QSA,L,NC]
# GROUPS ALL MODES
RewriteRule ^(group|[a-z0-9_-]*-g)([0-9]+)(-([0-9]+))?\.html$ /memberlist.php?mode=group&g=$2&start=$4 [QSA,L,NC]
# POSTS
RewriteRule ^post([0-9]+)\.html$ /viewtopic.php?p=$1 [QSA,L,NC]
# ACTIVE TOPICS
RewriteRule ^active-topics(-([0-9]+))?\.html$ /search.php?search_id=active_topics&start=$2&sr=topics [QSA,L,NC]
# UNANSWERED TOPICS
RewriteRule ^unanswered(-([0-9]+))?\.html$ /search.php?search_id=unanswered&start=$2&sr=topics [QSA,L,NC]
# NEW POSTS
RewriteRule ^newposts(-([0-9]+))?\.html$ /search.php?search_id=newposts&start=$2&sr=topics [QSA,L,NC]
# UNREAD POSTS
RewriteRule ^unreadposts(-([0-9]+))?\.html$ /search.php?search_id=unreadposts&start=$2 [QSA,L,NC]
# THE TEAM
RewriteRule ^the-team\.html$ /memberlist.php?mode=team [QSA,L,NC]
# HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES
# FORUM WITHOUT ID & DELIM ALL MODES
# THESE LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_-]+)/?(page([0-9]+)\.html)?$ /viewforum.php?forum_uri=$1&start=$3 [QSA,L,NC]
# FIX RELATIVE PATHS : FILES
RewriteRule ^(style\.php|ucp\.php|mcp\.php|faq\.php|posting\.php|download/file\.php|report\.php|adm/index\.php|cron\.php)$ /$1 [QSA,L,NC,R=301]
# FIX RELATIVE PATHS : IMAGES
RewriteRule ^.+/(styles/.*|images/.*|assets/.*|ext/.*)$ /$1 [QSA,L,NC,R=301]
#
# The following 3 lines will rewrite URLs passed through the front controller
# to not require app.php in the actual URL. In other words, a controller is
# by default accessed at /app.php/my/controller, but can also be accessed at
# /my/controller
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
有人可以帮我识别罪魁祸首规则并对其进行修改,以便始终传递任何 URL 参数而不是“删除”吗?