mit .htaccess
看起来像这样。
RewriteEngine on
RewriteRule !\.(js|gif|css|jpg|png|ico|txt|html)$ index.php [L]
它允许使用列出的文件扩展名正常访问URL。所有其他请求都将发送到index.php。
如何简化我的.htaccess,以便它允许所有文件请求并仅删除index.php没有文件扩展名的请求?
答案 0 :(得分:2)
我会这样做:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
我认为您的.htaccess位于您的文档中。否则试试:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
两个示例都会将所有流量发送到index.php,但实际存在的文件除外。