16
Nov
To avoid duplicate content problem with search engines, you have to redirect all pages to one common URL.
This you can achieve using mod_rewrite of apache and .htaccess.
To redirect any URL starting with www.domain.tld to domain.tld, you have to add the following code to .htaccess file.
Do a 301 redirect for all http requests that are going to the wrong url.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]
</IfModule>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]
</IfModule>
or
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.tld$ [NC]
RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.tld$ [NC]
RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
</IfModule>
To redirect domain.tld to www.domain.tld -
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]
</IfModule>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]
</IfModule>
or
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
</IfModule>
Share or Bookmark This Post With :
One Comment
|
|
Posted On November 28th, 2009
Please note the Google PageRank goes up to 10 and the best alexa rating is 1. Short Url Redirect |
Leave a Reply
Subscribe to RSS Feeds
Follow me on Twitter
Add to Favourite
Sponsors
Recent Posts
- Tweetie – Twitter client for iPhone
- PDFCreator – free tool to create PDF files f...
- Pidgin – the universal chat client
- Skyfire – Free & Fastest mobile web bro...
- Google Apps phasing out support for Microsoft Inte...
- Poedit – cross-platform gettext catalogs (.p...
- PDFmyURL.com – Convert and save pdf from any...
- Gallery – open source web based photo album ...
- ShoZu – Social Media Hub for Your Mobile
- Widsets is now OVI store
Most Popular
- Send emails using PHPMailer an...
- Firefox Addons Essential for S...
- URL Rewriting for PHP Web Appl...
- Free SEO Tools From SEOMoz.org...
- Multiple Instances of Tomcat w...
- Apache 2.x + Tomcat 4.x + Load...
- Pagination in JSP/Java
- PHP – Mysql Open Source ...
- java.lang.OutOfMemoryError: Ja...
- HOW TO Subversion+Apache on Fe...
Tags
add ons
Ajax
Apache
Browser
CSS
Date
email
featured
Fedora
FireFox
google
httpd
Image
Java
JavaScript
Jsp
linux
mobile applications
Mobile Apps
Mod JK
mozilla
Mysql
Open Source
Outlook
pagination
Performance
PHP
plugins
POP3
popular
Postfix
prototype
Resize
SEO
Servlet
Spamassassin
SSL
String
Subversion
themes
Tomcat
twitter
Unix
windows xp
WordPress





