php - htaccess - 如何允许访问其他文件
问题描述
目前我有以下 htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /v2/index.php?pg=$1 [L]
</IfModule>
什么在起作用?
http://site/v2/test -> 转到http://site/v2/index.php?pg=test
什么不工作?
如果我想加载 css 或 zip 文件..
http://site/v2/_downloads/download.zip
它转到:
http://site/v2/index.php?pg=_downloads/download.zip
但我想转到实际页面相同的 css 出于某种原因它加载:
http://site/v2/index.php?pg=_css/style.css
而不是http://site/v2/_css/style.css
我做错什么了?就是看不出来。。
解决方案
这似乎可以解决问题
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.bat|\.zip|\.rar|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /v2/index.php?pg=$1 [L]
#RewriteRule ^(.*)/$ v2/index.php?pg=$1 [L]
</IfModule>
推荐阅读
- python - Pandas Rolling:返回最小和最大日期,曝光总和
- python - 我收到一条错误消息,说“raw_input() 需要 1 到 2 个位置参数,但给出了 4 个”。我无法弄清楚出了什么问题
- r - 将 4x3 数据帧转换为 1 行数据帧
- google-data-studio - 如何在 Google Data Studio 中限制用户的数据?
- python - 按多列分组时“TypeError:无法将 bool 转换为 numpy.ndarray”
- regex - 打印包含特定字符串的文件的所有行
- python - 如何在 tensorflow 1.14.0 中有效地使用 OpenMP 并行性
- here-api - 布线距离 单向与反向
- angular - 在订阅 Observable 的响应时为变量赋值
- python - 如何将整数拆分为一位?