1

这是一个快速的问题。如何更改.htaccess文件以重写所有内容以将其重定向到index.php文件?

当我删除行时,RewriteCond我会得到一个505 Internal Server Error.

这是我的.htaccess文件:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
4

1 回答 1

1

您可以使用此规则:

RewriteEngine on

RewriteCond %{REQUEST_URI} !\.(?:jpe?g|gif|bmp|png|ico|tiff|css|js)$ [NC]
RewriteRule !^index\.php$ index.php [L,NC]
  • RewriteCond将跳过对 image/css/js 文件的重写。
  • 否定表达式!^index\.php$表示匹配除 之外的任何内容index.php
于 2016-11-23T11:40:24.260 回答