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 に答える