Categories
Web Server

How to Redirect a Directory Using Htaccess

There is occassion where you want to do a silent redirect (not a 301 redirect) from a directory to another directory.
Doing silent redirect will make browser to assume that this redirection is a brand new URL, not like 301 redirect which tells browser to open (redirected to) another URL.

We can use htaccess to do this 🙂

Categories
Web Server

Redirect Single URL with Htaccess

Sometimes you want to change some of your URL. For example you renamed your old html file. Or you have removed some of your old files and you want to redirect them to a new URL.

But maybe other websites have linked to your old URL. You can’t contact them to change the URL, or you are too lazy to contact them, or maybe there are just so many backlinks pointed to the old URL so it is quite hard to change them all.

To avoid losing link juice from other websites, we must redirect the old URL to the new URL, with permanent redirection.

Categories
Web Server Website

With or Without WWW

Folks, some of you have might have a website. For example you develop http://www.google.com (OF COURSE this is just an example :)). You might have a question, whether use http://google.com (w/o “www”), or http://www.google.com (w/ “www”). I don’t suggest that “www” is better, vice versa. But i’ll tell it about how to use with only, or without only.

The key is, you must create a .htaccess file in your root directory (or modify the old one if you’ve had it)

If you choose with www, use it in your .htaccess file


  RewriteEngine on

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