Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 拒绝访问index.php,但允许index.php?var=val_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 拒绝访问index.php,但允许index.php?var=val

.htaccess 拒绝访问index.php,但允许index.php?var=val,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我想知道我是否可以拒绝访问,只允许访问 使用rewritecond和rewriterule可以这样做吗?我想不出来。有什么帮助吗 谢谢 它必须是重写规则吗?如果是PHP脚本,您可以检测到缺少必需的参数,只需返回一个适当的HTTP头来拒绝访问。是的,这是可能的。在docroot.htaccess文件中使用条件检查查询字符串的技巧,该文件允许您禁止访问index.php,除非设置了变量var: RewriteEngine On RewriteBase / RewriteCond %{

我想知道我是否可以拒绝访问,只允许访问

使用rewritecond和rewriterule可以这样做吗?我想不出来。有什么帮助吗


谢谢

它必须是重写规则吗?如果是PHP脚本,您可以检测到缺少必需的参数,只需返回一个适当的HTTP头来拒绝访问。

是的,这是可能的。在docroot
.htaccess
文件中使用条件检查查询字符串的技巧,该文件允许您禁止访问index.php,除非设置了变量var:

RewriteEngine  On
RewriteBase    /

RewriteCond    %{QUERY_STRING}   !\bvar=
RewriteRule    index.php         -        [F]

谢谢你的回复!是的,它应该是.htaccess,因为index.php脚本是经过编码的,我无法修改它。