开发者

RewriteRule not working when file extensions included

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

I am currently using the following RewriteRule:

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

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.

I hav开发者_如何学Pythone tried doing it without the extension .css (i.e. http://example.com/style/universal) with the RewriteRule

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

Which works, but I would much prefer it if I could get it working with the .css extension.

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?

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

Any help would really be appreciated.

Thanks in advance, Brad.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜