Domain Redirection with HTAccess

The Scene

If you are playing with domain hack as I am, one thing to think about is to redirect the visitors reaching the primary domain to the sub-domain. For instance, I want to make sure whoever visits "" gets redirected to "" properly.

How do we do that? The answer varies depending on the method we take. I’m introducing a way which takes advantage of the mod_rewrite feature of apache servers.

The Solution

The relative paths look something like this:

/ <-

/del/ <-

Establish a .htaccess file in the root directory with content below:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$1 [R,L]

This way each request to "" will be redirected to "". Follow the htaccess tutorial and modify RewriteRule to create more complicated redirection rules as you wish.

Technorati Tags: ,






《“Domain Redirection with HTAccess”》 有 1 条评论

  1. linkan 的头像

    Nice to read the Information about the Domain name Registration article.. fine useful for me.I found the Domain name registration site named as


您的电子邮箱地址不会被公开。 必填项已用 * 标注