我知道这是一个常见问题,但我无法在 SO 找到解决我的问题的方法
htaccess 是
RewriteEngine On
RewriteBase /app/
RewriteCond ${REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond ${REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
index.php 只包含一个 require
到存在 html 的 index.html。
我试过使用 /
在我的 css 相对路径上,但没有任何变化。我也用过 <base href="/">
但也没有任何改变。指令
RewriteRule ^(.+?\.(?:jpe?g|gif|bmp|png|tiff|css|js))$ /$1 [NC,L]
也不要解决问题。
更新。问题已解决
我检查了错误日志中的错误 variable ${REQUEST_FILENAME} is not defined
显示。这么变$
至 %
在.htaccess
解决问题
最佳答案
请注意,在 Apache httpd 2.2.16 及更高版本中,有一个新指令正是为这种情况而创建的。它称为 FallbackResource。参见 http://httpd.apache.org/docs/current/mod/mod_dir.html#fallbackresource
在你的情况下,你想要:
FallbackResource /app/index.php
关于php - .htaccess 重写规则导致 css、js 停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39507996/