1

要求されたファイルがディレクトリに関係なく index.php である場合、別のサイトにリダイレクトされるように、(できれば RewriteCond を使用して) リダイレクトを設定したいと思います。

したがって、/index.php、/files/index.php、または /stuff/index.php (など) にアクセスすると、すべて別のドメインにリダイレクトされます。

4

2 に答える 2

7

ここでは、一般的な方法を示します。このルール セットは、ルート ディレクトリの .htaccess ファイルに配置する必要があります。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  index\.php/?       [NC]
RewriteRule .*  http://otherdomain.com/      [R=301,L]

index.php次のように、任意の位置にある URL を永久にリダイレクトします。

http://mydomain.com/index.phpまた

http://mydomain.com/any/folder/quantity/index.phpまた

http://mydomain.com/any/folder/quantity/index.php/any/folder/quantity/

http://otherdomain.com/

それでおしまい。質問で言うように、あまり説明しないので、他のドメインには何も渡されません。

...別のサイトにリダイレクトされました。

于 2013-01-21T21:21:04.863 に答える
2

これらのルールはそれを行う必要があります(/.htaccessファイル内に配置されている場合):

RewriteEngine On
RewriteRule (?:^|/)index\.php$  http://otherdomain.com/ [R=301,L]
于 2013-01-21T21:27:53.210 に答える