2

基本上我不希望访问我网站的人获取所有文件,但是我在互联网上尝试和发现的所有东西都不允许在 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
4

1 回答 1

1

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

# block direct requests to index.php and redirect it to /
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index.php$ /

如果需要,您可以更改重写目标和/或根据确切允许的内容和不允许的内容添加更多条件。

于 2012-11-15T12:44:11.243 回答