.htaccess 拒绝访问index.php以外的所有文件,但允许获取变量

.htaccess 拒绝访问index.php以外的所有文件,但允许获取变量,.htaccess,rewrite,.htaccess,Rewrite,基本上,我不希望访问我网站的人获取所有文件,但我在互联网上尝试和发现的所有东西都不允许在index.php之后使用get变量。我正在使用重写使domain.com/lol转到index.php?lol 这是我当前的.htaccess文件,如果您想修改它以使我更方便,请继续 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC] RewriteRule .? http://domain.com%{REQUEST_URI}

基本上,我不希望访问我网站的人获取所有文件,但我在互联网上尝试和发现的所有东西都不允许在index.php之后使用get变量。我正在使用重写使domain.com/lol转到index.php?lol

这是我当前的.htaccess文件,如果您想修改它以使我更方便,请继续

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]

RewriteRule .? http://domain.com%{REQUEST_URI} [L,R=301]
RewriteRule ^act/(.*)$ index.php?act=$1
RewriteRule ^code/(.*)$ index.php?code=$1
RewriteRule ^login$ index.php?login
RewriteRule ^logout$ index.php?logout
RewriteRule ^add$ index.php?add
RewriteRule ^tac$ index.php?tac
RewriteRule ^profile$ index.php?profile

以下规则停止对index.php(带或不带)参数的直接请求:

# block direct requests to index.php and redirect it to /
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index.php$ /
如果需要,您可以更改重写目标和/或根据确切允许和不允许的内容添加更多条件