当文件扩展名重写规则不工作 [英] RewriteRule not working when file extensions included

查看:125
本文介绍了当文件扩展名重写规则不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我试图使用mod_rewrite使 http://example.com/style/universal.css 显示页面 HTTP: //example.com/style.php?n=universal

Hey, I am trying to use mod_rewrite to make http://example.com/style/universal.css show the page http://example.com/style.php?n=universal

我目前使用下面的重写规则

RewriteRule ^style/([^/\.]+)\.css$ style.php?n=$1

但它似乎并没有工作,由于某种原因,而不是显示了 404未找​​到这甚至不是正确的404页。

But it doesn't seem to work, for some reason it instead shows a 404 Not Found which is not even the correct 404 page.

我曾尝试这样做没有扩展名的.css (即 http://example.com/style/universal )的重写规则

I have tried doing it without the extension .css (i.e. http://example.com/style/universal) with the RewriteRule

RewriteRule ^style/([^/\.]+)$ style.php?n=$1

这工作,但我更preFER它,如果我能得到它与的.css 扩展工作。

这似乎是一些与服务器忽略重写规则,如果一个文件的扩展名被使用。是否有一个的RewriteCond 或明显的东西,我很想念?

It seems to be something with the server ignoring the RewriteRule if a file extension is used. Is there a RewriteCond or something obvious that I am missing?

我还要提到的是有一个的.htaccess 在由字preSS设置的父目录,这样的内容:

I should also mention that there is a .htaccess in the parent directory which is set by WordPress, the contents of this are:

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

任何帮助真的会AP preciated。

Any help would really be appreciated.

在此先感谢,布拉德。

推荐答案

设置您的mod_rewrite记录所有的步骤,它不处理你的网址

Set up your mod_rewrite to log all the steps it does processing your url

RewriteLog "/tmp/mysite_rewrite.log"
RewriteLogLevel 6

阅读日志,你应该能够理解你的网址是如何改写,这是什么问题。

reading the logs you should be able to understand how your url is rewritten and what is the problem.

这篇关于当文件扩展名重写规则不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆