Forum Moderators: phranque
Your existing rules 1 to 6, should be re-ordered 6 - 4 - 5 - 2 - 3 - 1 and a question mark added to the redirect target of at least the first five rules.
I would not redirect all query strings to the root. I would strip only the query string from the original URL and redirect to that
I would not redirect all query strings to the root. I would strip only the query string from the original URL and redirect to that
# if the "/" page is not supposed to have a query string or non-blank query
RewriteCond %{QUERY_STRING} .
# Redirect to "/" after clearing query string
RewriteRule ^$ http://www.example.com/? [R=301,L]
# Externally redirect all non-blank non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect request for URL-path /old-page.html to www.example.com/new-page.php
RewriteRule ^old-page\.html$ http://www.example.com/new-page.php [R=301,L]
A further complication is that my host has disabled htaccess inheritance in order to facilitate their custom access logging package. Therefore most of the www htaccess data has to be repeated in the subdomain htaccess file. (Very inefficient, but apparently my fellow virtual hosters can't live without tagged access logging!)