|Preventing rewrite of a root request|
but everything else gets rewritten
| 12:28 pm on Jan 31, 2009 (gmt 0)|
I have a site which is rewriting all urls to the main index.php file.
However, I DON'T want it to rewrite the main url - I want that to go to index.html (where we have a holding page).
The .htaccess rule for the rewrite is simple:
RewriteCond $1 !^(index\.php¦images¦robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
But how do I stop it from rewriting the root www.example.com ?
Thanks in advance for any help :-)
| 3:29 pm on Jan 31, 2009 (gmt 0)|
Change (.*) in the rule to (.+)
Neither the start nor the end anchor are needed, since these are both 'greedy' patterns.
| 3:51 pm on Jan 31, 2009 (gmt 0)|
Thanks so much, I never would have figured that one out, much appreciated.
| 6:17 pm on Jan 31, 2009 (gmt 0)|
You rule also rewrites searchengine verification file URLs and a whole host of other stuff that you probably don't want to rewrite.
| 12:22 pm on Feb 1, 2009 (gmt 0)|
That bad? I'm using CodeIgnitor, and that's the suggested rule they give in their User Guide. If there's a better option, please pass it on to me and I'll post it to their forums to share with others. Many thanks.
| 6:54 pm on Feb 1, 2009 (gmt 0)|
Unless excluded, *all* requests must be handled properly by the script.
I'm not familiar with CodeIgniter, but you'd also do well to test thoroughly to make sure that if it cannot find a requested resource, it returns a proper 404-Not Found header, and NOT a 200-OK (no matter what the page content it returns might be).