1
如果reaquest参数未指定值,即“/?qwerty”(其中“qwerty”表示无效参数,没有'='和任何值),我必须重定向到现场。我写过.htaccess文件(网站与Joomla合作)。您可以看到以下片段:如何将参数未通过.htaccess赋值的URL重定向到404页面?
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [OR]
#Next string redirects all of requests with parameters
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_] [NC]
RewriteRule ^(.*)$ index.php [R=404,L]
但现在网站无法处理任何带参数的请求。我怎么解决这个问题?
谢谢,但我的意思是它必须重定向任何参数名称。您给了我一个主意,下面的代码按照我的意愿工作: 'RewriteCond%{QUERY_STRING}^[a-zA-Z0-9 _] + $ [OR] RewriteCond%{QUERY_STRING}^[a-zA-Z0-9_ ] + = $ [NC] RewriteRule^$ - [R = 404,L]' – andreytemn