我尝试在使用特定域名时添加默认参数,而不需要任何其他信息,例如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
答案 0 :(得分:0)
尝试将标记R
添加到重写规则中。 R
表示重定向,并指示服务器重定向。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} "^$"
RewriteBase /
RewriteRule ^(.*)$ ?s=hashvalue [QSA,L,R]
您可以在Apache站点上找到有关标志的更多信息: