php - 不要重写代表文件的 URL

标签 php regex mod-rewrite url-rewriting

# These settings routes all traffic, except concrete files, to the dispatcher

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ index.php [NC,L]

问题是它确实将具体文件路由到调度程序:(

如何才能忽略像 http://site.com/style.css 这样的 URL?

最佳答案

试试这个并让我知道:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.php [NC,L]

您将所有内容重写到index.php,这将检查文件/文件夹/符号链接(symbolic link)是否存在,然后加载文件(如果存在)。

关于php - 不要重写代表文件的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9370875/

相关文章:

php - 从 Lumen/Laravel 中的路由中删除 index.php

regex - 如何使用 Notepad++ 正则表达式搜索匹配 HTML 属性?

apache - 从 symfony 的 url 中删除 www 和 index.php

php codeigniter 计算行数

php - Ajax不显示mysql数据库的结果

php - PHP和Redis缓存

wordpress - 将 joomla url 重定向到 wordpress

python - 如何从匹配的表达式中找到特定的单词?

regex - 如何使用 smartmatch 检查字符串是否与数组中的所有模式匹配?

regex - .htaccess 使用哪种正则表达式?