Forum Moderators: phranque
It is my understanding that we go from most general to most specific, but I want to be sure I have this right.
So...
#Rewrite will be used more later, but
RewriteEngine On
# We start by adding this to redirect oldsite.com to newsite, using the rule of
# most general to most specific. Also can add any other URLS that need to be
# redirecton on this server - correct?
RewriteRule ^(.*)$ [newsite.com...] [R=301,L]
#Now we map the old pages to the new, one by one
redirect 301 old-page.php [newsite.com...]
redirect 301 old-page.php [newsite.com...]
#etc....
# Now specific rewrites for the CMS
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_URI} (/¦\.htm¦\.php¦\.html¦/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule (.*) index.php
Unfortunately, the above gives me an internal server error. Clues as to what I am doing wrong?
# If request to non-canonical domain, redirect to canonical domain
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Follow these external redirect rules with your internal rewrites, again from most-specific to least specific, as outlined above. Your 'Joomla' rewrite should be the last (or one of the last) rewrites in your .htaccess file.
[added] Also, for best results, you'll want to enforce the order of execution of your rules. To allow this, do not mix directives from different modules. That is, use mod_rewrite or mod_alias, not both as you've done above. Redirect is a mod_alias directive, while RewriteRule is handled by mod_rewrite. It is the server configuration which decides whether mod_alias or mod_rewrite directives are processed first, and you cannot control that by ordering the directives in your .htaccess file. In other words, the server will process all mod_alias directives first, followed by all mod_rewrite directives, or vice-versa, depending on how it's configured. So in order to enforce order of execution while using advanced features like "check requested host name" and "check for file exists" as you have done, you'll have to use mod_rewrite only, because mod_alias does not support those features. [/added]
Jim
[edited by: jdMorgan at 3:41 pm (utc) on Jan. 13, 2008]
I just want to thank you for your patience and the depth of your responses in this forum. I am always impressed by how well you explain not just what to do, but why to do it. You are able to simplify a very complex subject and share it in a non-threatening way. A great teacher!
I have yet to return to the problem at hand, but I expect that your response will prove invaluable in solving the problem.