Regex 包含文件扩展名时重写规则不起作用
嘿,我正在尝试使用mod_rewrite来制作Regex 包含文件扩展名时重写规则不起作用,regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,嘿,我正在尝试使用mod_rewrite来制作http://example.com/style/universal.css显示页面http://example.com/style.php?n=universal 我目前正在使用以下重写规则: RewriteRule ^style/([^/\.]+)\.css$ style.php?n=$1 但它似乎不起作用,出于某种原因,它反而显示了一个404notfound,它甚至不是正确的404页面 我尝试过不使用扩展名.css(即http://examp
http://example.com/style/universal.css
显示页面http://example.com/style.php?n=universal
我目前正在使用以下重写规则
:
RewriteRule ^style/([^/\.]+)\.css$ style.php?n=$1
但它似乎不起作用,出于某种原因,它反而显示了一个404notfound
,它甚至不是正确的404页面
我尝试过不使用扩展名.css
(即http://example.com/style/universal
)使用重写规则
RewriteRule ^style/([^/\.]+)$ style.php?n=$1
这是可行的,但如果我能让它与.css
扩展一起工作,我会更喜欢它
如果使用文件扩展名,服务器似乎会忽略重写规则。是否有RewriteCond
或明显缺少的内容
我还应该提到,WordPress设置的父目录中有一个.htaccess
,其内容如下:
RewriteEngine on
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
重新编写引擎打开
#开始WordPress
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
任何帮助都将不胜感激
提前谢谢你,Brad。设置你的mod_rewrite,记录它处理url的所有步骤
RewriteLog "/tmp/mysite_rewrite.log"
RewriteLogLevel 6
通过阅读日志,您应该能够了解url是如何重写的以及问题所在。FWIW,如果您确保从PHP脚本发送
内容类型:text/css
HTTP头,则不需要.css
扩展名。我没有自己的服务器。还有其他的调试方法吗?