Apache - RewriteRule 删除了 url 参数



我尝试在使用特定域名时添加默认参数,而无需任何其他信息,例如ht tp://www.mydomain.com[NOTHINGHERE]

Apache 不断删除参数,进行一些奇怪的拆分并丢弃它,尽管我尝试了许多选项 SDI,QSA,L...

这是安静的简单规则:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} "^$"
RewriteRule ^(.*)$ ?s=somehashvalue [QSA,L]

这是日志:

init rewrite engine with requested uri /
pass through /
[perdir /somedironmyserver/] strip per-dir prefix: /somedironmyserver/ ->
[perdir /somedironmyserver/] applying pattern '^(.*)$' to uri ''
[perdir /somedironmyserver/] RewriteCond: input='/somedironmyserver/' pattern='!-f' => matched
[perdir /somedironmyserver/] RewriteCond: input='' pattern='^$' => matched
[perdir /somedironmyserver/] rewrite '' -> '?s=somehashvalue'
split uri=?s=somehashvalue-> uri=, args=s=somehashvalue
[perdir /somedironmyserver/] add per-dir prefix:  -> /somedironmyserver/
[perdir /somedironmyserver/] initial URL equal rewritten URL: /somedironmyserver/ [IGNORING REWRITE]
init rewrite engine with requested uri /index.html
pass through /index.html
[perdir /somedironmyserver/] strip per-dir prefix: /somedironmyserver/index.html -> index.html
[perdir /somedironmyserver/] applying pattern '^(.*)$' to uri 'index.html'
[perdir /somedironmyserver/] RewriteCond: input='/somedironmyserver/index.html' pattern='!-f' => not-matched
[perdir /somedironmyserver/] pass through /somedironmyserver/index.html

尝试将标志R添加到重写规则中。 R表示重定向并指示服务器重定向。

            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{QUERY_STRING} "^$"
            RewriteBase /
            RewriteRule ^(.*)$ ?s=hashvalue [QSA,L,R]

您可以在 Apache 网站上找到有关标志的更多信息:

https://httpd.apache.org/docs/2.4/rewrite/flags.html

最新更新