|Preventing rewrite of a root request|
but everything else gets rewritten
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 :-)
Change (.*) in the rule to (.+)
Neither the start nor the end anchor are needed, since these are both 'greedy' patterns.
Thanks so much, I never would have figured that one out, much appreciated.
You rule also rewrites searchengine verification file URLs and a whole host of other stuff that you probably don't want to rewrite.
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.
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).