| Preventing rewrite of a root request but everything else gets rewritten |
AnonyMouse

msg:3838896 | 12:28 pm on Jan 31, 2009 (gmt 0) | Hi, 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: RewriteEngine on 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 :-)
|
jdMorgan

msg:3839065 | 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. Jim
|
AnonyMouse

msg:3839101 | 3:51 pm on Jan 31, 2009 (gmt 0) | Thanks so much, I never would have figured that one out, much appreciated.
|
g1smd

msg:3839206 | 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.
|
AnonyMouse

msg:3839652 | 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.
|
jdMorgan

msg:3839792 | 6:54 pm on Feb 1, 2009 (gmt 0) | The point is simply that the RewriteCond may need to exclude other "common" URL-paths such as requests for /sitemap.xml, /w3c/p3p.xml, /labels.rdf, and search engine "webmaster tools" validation files such as /google<16 hexadecimal digits>.html, /y_key_<16 hexadecimal digits>.html, and /LiveSearchSiteAuth.xml, other files not handled by your script such as external CSS stylesheets and JavaScript files, .pdf and .xls, files, multimedia files, and /favicon.ico. 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). Jim
|
|
|