Forum Moderators: phranque
I have 2 domain names for one website
old-domain.com
new-domain.com
I only want everyone to use new-domain.com
What is best performance wise?
A) Use html refrech meta tag:
<META HTTP-EQUIV="Refresh" Content="0; URL=http://www.new-domain.com/dir1/">
#!/usr/bin/perl
print "Status: 301 Moved\r\n" .
"Location: http://www.new-domain.com/\r\n" .
"\r\n";
<?php
header("Location: http://www.new-domain.com/");
?>
Redirect permanent / http://www.new-domain.com/
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old-domain.com
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=permanent,L]
I guess Redirect? option D
What do you think?
Cheers,
Bastiaan
Solution D will work if the www and non-www domains resolve to different <VirtualHost> configuration containers or .htaccess files. If they do not, then you will have to use solution E, because solution D will loop recursively on requests for the "www" domain.
Jim
I would use E because you shouldn't mix (Mod_Auth redirects) and (Mod_Rewrite rewrites and redirects) in the same .htaccess file.
There are times when C is the best thing to use.
I would never use A, as it is too risky.
However, any code that is executed on the server side, including PHP, PERL, etc. introduces *some* overhead, and the question is, "Is the execution overhead worth the benefit?" If it is, then let the server do the work and don't worry about it -- except to make a good attempt to use efficient coding and efficient methods to implement the the functions you need.
When putting your code into http.conf, apache2.conf, or conf.d is an option, then the only significant advantage to putting code into .htaccess is that you don't have to re-start the server after making changes to that code. So using .htaccess is often useful for testing. But having debugged the code, moving it into the server configuration is certainly worthwhile -- if you have that option.
Jim