Page is a not externally linkable
lizardx - 8:23 pm on Feb 4, 2008 (gmt 0)
That did it. I almost thought it didn't, but then I realized I had slightly changed your code, removing the L in [R=301,L], which of course then cascades down to the QSA conditions, which then resulted in an internal modx 404. As soon as I used your exact code, which I think I now understand, correct me if this is wrong, it worked as expected: 1. Initial request is made to apache for non www url. I was almost going to say this didn't work, but then I remembered who was giving the advice, in which case, it's far more likely I did something slightly wrong. The . case is interesting, I didn't know about that option, that's the clean code I suspected existed and which my hack was trying to emulate. I'm going to take a closer look at the optimizing code, not for this site, which will never see enough visitors to warrant that much dev time, but for one of my more popular sites, that might benefit from such optimizations. Thanks a lot for your input, that's one glitch I couldn't resolve on my own, and thanks for your ongoing Apache support.
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule (.*) index.php?q=$1 [QSA,L]
2. Request is 301ed to www url, and that process ends.
3. New request for www url is received, and that request is then handled by the QSA condition.