I am trying to set up canonical redirects in my .htaccess file in order to manage my domains. The situation is complicated by the fact that there is already a set of rewrite rules in place for the CMS, (Joomla). My approach was to not mark the canonical redirects as final, and to place them before the SEF rewite rule block for Joomla.
The result sort of works, in that a request for pages at 3dify.com, threedify.com, or www.3dify.com will always return http://www.threedify.com/index.php. The problem is that the rest of the URL is ignored instead of being appended to the new domain, so any request for a page at a non-canonical domain ALWAYS redirects to the site index.
This isn't what I want. I would like to return the requested page from the canonical URL, not redirect to the site root. Why is the $1 getting chomped? Does anyone have any ideas for me?
Actually, no, that isn't what I wanted to do. If you look at the rules I wrote, You'll see that I wanted to rewrite 3 domains to match the canonical domain. It turns out that if I set the rule to final (add an "L" flag) it completes processing on the canonical redirect before applying the SEF rewrite block for the CMS. This will work provided my rewrite block appears before the CMS block.
So, if you have multiple virtual hosts listed, you would put something like this in the top-listed host as a catch-all. All hosts that don't explicitly match a virtual host get routed to the first-listed virtual host. Such requests are then redirected to the preferred hostname. (if they are not already requests for the preferred hostname)
ADDENDUM: I suppose there may be a danger in giving someone the impression that Svidgen is somehow affiliated with somepornsite.com ...
... if that becomes an issue, I would modify my host header matching condition to redirect only domains and subdomains that I own. But, I'm only worried about it if Svidgen gains the popularity necessary to warrant attacks on its image.