Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 包含文件扩展名时重写规则不起作用_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

Regex 包含文件扩展名时重写规则不起作用

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

嘿,我正在尝试使用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://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
扩展名。我没有自己的服务器。还有其他的调试方法吗?