6

ご挨拶、

Web サイトを IIS から Apache に移動したばかりで、無限ループを引き起こさずにインデックス ファイルをリダイレクトするのに少し問題があります。

これらの両方が個別にループを引き起こします-

リダイレクト 301 /index.htm /index.php

リダイレクト 301 /index.htm http://www.foo.com/

以下は、現在の .htaccess のコピーです。誰かが私を助けることができますか?http://www.foo.com/index.htmを指しているリンクがたくさんありますが、これをhttp://www.foo.com/に 301 リダイレクトしたいと考えています。

RewriteEngine On

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

# RewriteBase /

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|\.cfm|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

Redirect 301 /a /administrator
4

5 に答える 5

6

なぜあなたはこれをやっている?有効なインデックス拡張機能として index.php を vhost/config に追加しない理由

DirectoryIndex index.html index.php

そして、HTMLファイルを削除します>

また

DirectoryIndex index.php
于 2009-05-18T13:32:22.633 に答える
3

ディレクトリ インデックスが index.html に設定されていて、index.php の前にあると思います。次に、http://www.foo.com/は http://www.foo.com/index.html として解釈され、http://www.foo.com/にリダイレクトされます-したがってループ。

ここでは、さまざまな方法でのリダイレクトに関する情報を入手しました。

于 2009-05-18T13:31:52.137 に答える
1

次のように REQUEST_URI の値を確認する必要があります。

RewriteCond %{REQUEST_URI} ^/index.htm$     # If REQUEST_URI == "/index.htm"
RewriteRule (.*) / [R=301,L]                # Then 301 redirect to "/"
于 2012-02-17T21:06:34.107 に答える
0

リダイレクト ループに関する Kender のコメントに同意します。おそらくそれが持つべき方法

DirectoryIndex notindex.html

リダイレクトとともに、実際のフロント ページを notindex.html に配置します。そのページが本当に存在する場合、 /index.html を使用している人々の何が問題なのかわかりませんか?

于 2009-05-18T13:35:54.310 に答える
0

私はまだ新しいユーザーなので、ハイパーリンクを追加することは許可されていません。「foo」と入力したら、それが URL 全体であると想定してください...

ループなしで foo/index.php を foo/ にリダイレクトするには、別の書き換えルールを使用します。

RewriteRule index.php foo/ [R=301]

RewriteBase の設定 (および index.php があるディレクトリの数) によっては、/index.php を使用する必要がある場合があります。

于 2009-05-26T10:43:15.277 に答える