27 December 2008 Categorized under Internet

Setting a preferred domain for your blog

The preferred domain means the address you want your visitors to see when they come to your site. That is http://exnol.com or http://www.exnol.com in my case. you can do this easily if you are on Apache. edit the .htaccess file as follows :

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

If an htaccess file doesn’t exist, add the above code to a text file, name it .htaccess and save it at your root directory.If ReWriteEngine On is already in your htaccess file the ignore the first line.  Replace YOURDOMAIN with your sites domain name. There can be problems if you use this along with

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

If you use them together some problems may occur during file access.

RewriteEngine on
This line starts the mod_rewrite module
RewriteCond %{REQUEST_FILENAME} !-d
If the request is for a real directory (one that exists on the server), index.php isn’t served.
RewriteCond %{REQUEST_FILENAME} !-f
If the request is for a file that exists already on the server, index.php isn’t served.
RewriteRule ^(.*)$ /index.php

So there can be errors. I faced them while rewriting my .htaccess file but doesn’t remember the error correctly.


Some related articles you may like :

  1. Setting a FAVorite ICON for your site
    This post is an Answer to the comment posted by Carol A Ranney on “How to make custom icons”. A favourite icon commonly known as...
  2. Google has removed the warning for results from this blog
    After many review requests to and have finally removed the warning “This site may harm your computer!” from the results of this blog. My previous...
  3. Setting the correct aspect ratio for a video
    How you can correct the wrong width to height ratio in a vieo using VLC player....
  4. How to get your new blog post indexed instantly by Google
    You can get Google to index your new blog post very fast. The trick is to ping your blog using Google blogsearch. Here are some...
  5. How to use affiliate links without loosing your PR?
    Of late Google has been penalising blogs and sites that are using affiliate links in their page. This is because affiliate links are not actually pointers to...
  6. How to secure your Wordpress installation against hackers
    Matt Cutts last day did a post on securing your Wordpress installation from hackers. He had some really nice tips which are highly useful. So...

Leave a Reply