我正在使用以下.htaccess文件尝试不允许 访问物理php文件并将请求重定向到index.php。 它工作得很好,但带来了问题。
对png文件或图标文件的引用被重定向(逻辑上:()到index.php。 我试图添加规则以避免这种情况,但我失败了。
关于如何不将png和图标文件重定向到index.php的任何想法?
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
#Secure access to php files except from index.php
<FilesMatch "\.php$">
Order Allow,Deny
Deny from all
</FilesMatch>
#Allow access only to index files of each folder.
<FilesMatch "^(index)\.php$">
Order Allow,Deny
Allow from all
</FilesMatch>
# Index.php is the only gateway to the webapp
# If the request is for a real directory (one that exists on the server), index.php isn't served.
RewriteCond %{REQUEST_FILENAME} !-f
#If the request is for a file that exists already on the server, index.php isn't served.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]