Thursday, February 10, 2011

Redirect requests to non-www to www


Masuk ke cpanel
Cari file .htaccess
Edit dengan filemanager di web.

Copikan script berikut ini :

# Require WWW
# Will automatically redirect requests to non-www to www
# This will exempt robots.txt for search engines

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/robots\.txt$
RewriteCond %{REQUEST_URI} !^/sitemap\.(xml|xml\.gz)$
RewriteCond %{HTTP_HOST} ^([^.]+)\.([^.]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1.%2/$1 [R=301,L]

Semoga berhasil. :)

1 comment:

Anonymous said...

Hi. I wanted to drop you a quick note to express my thanks. I've been following your blog for a month or so and have picked up a ton

of good information as well as enjoyed the way you've structured your site. I am attempting to run my own blog but I think its too

general and I want to focus more on smaller topics. Being all things to all people is not all that its cracked up to be.



Web Development