Is there a better expression?

Topics: User Forum
Apr 8, 2008 at 3:21 PM
Hi all...
Here is the rewrite rule I was using for my wordpress blog:

RewriteRule ^/blog/(?!index\.php)(?!wp-)(.*)$ /blog/index.php/$1

This worked for 99% of the pages, but it would not let me access files on the root of the blog /blog/<here>. For example, if I wanted to access /blog/readme.html I would get a 404 page. This was a problem especially for my sitemap.xml file.

I rewrote the rule adding in the part in bold below:

RewriteRule ^/blog/(?!index\.php)(?!wp-)(?!.*\..*)(.*)$ /blog/index.php/$1

It seems to work just fine now, but I was just curious to know if there was a better expression I should be using?

Apr 9, 2008 at 3:26 PM
Edited Apr 9, 2008 at 3:29 PM
Hey, that's a nice rule. I'm doing exactly the same thing - running Wordpress under IIS - and if you enjoy alternatives, here's what I came up with (before I found your post):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /(.*) /index.php/$1 [U,I,L]

I've only been using it for a day. I can't tell you which is better, but this one seems to be working for me (in IIRF 1.2.12c that is, this doesn't work in 1.2.13 beta due to a bug I think.)

I haven't tried your solution, but I copied it into my ini file as a comment in case I have any problems and need to experiment. Thanks for posting this.

- Tony
Apr 19, 2008 at 8:40 PM
Hey, thanks for the reply. I think your makes more sense -- actually check to see if it's a valid directory or file first. I wonder if it affects performance.
Honestly, I think I like yours better, but indeed it does not work with 1.2.13. For some reason the rewrite conditions checking for a file fails returning a false when it should return a true.
I switched to 1.2.12c to see how it works.
Glad you put this up!!!