l_c,
It looks like the canonical code requires that the script be dedicated to the (singular) content.
IMF,
Okay, redirect to a single URI is a smart thing to do. Where I have a minor hang-up is stripping the DirectoryIndex off the domain as you do with
RewriteCond %{QUERY_STRING} ^page=1$
RewriteRule ^index\\.php$ http://domain.com/? [R=301,L]
Yes, the trailing / in the redirection is required to DELETE any pre-existing query string, i.e., page=1, and you specified that correctly. Adding that to index.php does nothing to enable the redirection, only to remove the query string.
The No Case Flag makes regex case insensitive, i.e., it makes [a-z] have the same effect as [a-zA-Z]. Because Apache requires the exact match (unless you’re using mod_speling) to serve a script, it makes no sense to use it in a RewriteRule statement. As I said before, {HTTP_HOST} is not case sensitive so it’s designed to work against similar variables which are not case sensitive.
Hosts can configure their server to show the DirectoryIndex - not many do - so redirecting to remove the DirectoryIndex from the {REQUEST_URI} can cause a loop. Simple statement. IMHO, it’s not worthwhile doing this.
Please use [noparse]
...
[/noparse] wrappers rather than PHP.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^index\\.php?$ http://domain.com/ [R=301,L]
RewriteCond %{QUERY_STRING} ^page=1$
RewriteRule ^index\\.php$ http://domain.com/? [R=301,L]
Corrected above.
Ouch! That was a complex explanation to ask to remove a leading & from a query string!
...
# Remove leading & from query string
RewriteCond %{QUERY_STRING} ^&(.*)$
RewriteRule .? %REQUEST_URI}?%1 [R=301,L]
Regards,
DK