301 redirect - apache or php for my case?

I have a blog www.SITE_NAME.com which is hosted in blogger.com, Its almost 4 year old and have better search engine ranking. Most of the traffic came through Google. Now i am redesigning my site in drupal.

So i want to redirect all older links with a 301 to new pages , Since i have nearly 700 pages , i want some logic to apply (and some case i want to redirect manually) . Which is better, using Apache or php? Or any other suggestion?

Note : since my old site is in blogger.com, its path is something like this www.SITE_NAME.com/2007/08/music.html and my new path will be like www.SITE_NAME.com/DYNAMIC_PATH

Answers


These scripts should be placed in the .htaccess file.

//*301 Redirect: xyz-site.com to www.xyz-site.com

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.xyz-site.com$ [NC]
RewriteRule ^(.*)$ http://www.xyz-site.com/$1 [L,R=301]

//*301 Redirect: www.xyz-site.com to xyz-site.com

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^xyz-site.com$ [NC]
RewriteRule ^(.*)$ http://xyz-site.com/$1 [L,R=301]

//*301 Redirect: Redirecting Individual pages

Redirect 301 /previous-page.html http://www.xyz-site.com/new-page.html

Or you can use

Redirect with PHP

<?php
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.xyz-site.com" );
exit(0);
?>

if we are talking about performance, - then defiantly .htaccess/apache will be better/faster. if you wanna implement some logic on redirect, when probably it will be easier to do with php, using headers.


Definitely use the 301. It lets search engines know that the site is moved permanently and should transfer any "link weighting" from the old URL to the new one. Check out this info from Google Webmasters

And this about redirecting tons of links


Sorry I can't post comments yet. If the domain is the same, you should "bild" same site structure (same permalinks) and I guess use something like this:

http://drupal.org/project/blogger_importer

Then you should not use any redirects at all.


Need Your Help

Iterating on each element from an array of arrays on Postgresql

sql arrays postgresql plpgsql postgresql-8.3

I have a VARCHAR of numbers inside my stored procedure, these numbers are organized as arrays, I will show an example below:

html body tag limitations in chrome and 'I.E'

php javascript jquery html

to boost up the performance of the web site i put all the contents from the db ( not very big ) to body data tag. i.e.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.