私たちは何年もの間、次のファイルを使用しています:.htaccess
我々はApache 2.4.7
を使用しています。何らかの理由で、静的なファイルがフロントコントローラに当たっているようですindex.php
!なぜこの.htaccessファイルはスタティックファイルをフロントコントローラにルーティングしていますか?
例:https://example.com/apple-touch-icon.png
は、応答ヘッダーがX-Powered-By:PHP/5.5.9-1ubuntu4.3
を含むことがわかるように、フロントコントローラーによって処理されています。
誰でも問題を見つけることができますか?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
### Force SSL
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$/[L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce NO www
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
「ErrorDocument 404/index.php」をコメントアウトして同じ 'png'ファイルをリロードする – anubhava
それは原因です!おそらくあなたは正しい答えとしてマークすることができるように答えを加えることができます。なぜIfModule !mod_rewrite.c'は実行されましたか? – Abs
奇妙な... ''は実行しないでください!そして、それが実行された場合、反対側のブロック( '')も実行できませんか?しかし、 'ErrorDocument'が処理された場合、' .png'が存在していればそれは問題ではありません。しかし、あなたはプロキシの背後にあります...それはそれと関係がありますか?ちなみに、 'RewriteCond'ディレクティブが常に失敗するため、' REQUEST_URI'サーバ変数は常にスラッシュ_で始まりますので、ユーザがシステムフォルダへのアクセスを削除するルールは何もしません。 –
MrWhite