Redirect to a Different URL using .htaccess

Basic Redirect

You can use .htaccess to redirect users to a different URL. The most basic .htaccess looks for any request for a specific page and if it finds that request, it forwards it to a new page you have specified. The syntax is:

redirect accessed-file URL-to-go-to

There are 3 parts;

(1) the Redirect command, 
(2) the location of the file/directory you want redirected, and 
(3) the full URL of the location you want that request sent to. 

These parts are separated by a single space and should be on one line.

For example, if you want to redirect users from oldfile.html in the www directory of your account, to newpage.html, the syntax should be

redirect /~account/oldfile.html

Anyone going to will end up on

You must use a full URL even if you're going to send the users to another page on your own site.

You can also redirect an entire directory:

redirect /~account/old_dir/

Anyone going to will end up on

Redirect tilde URL (i.e. /~account/) to an existing virtual host

These instructions apply to accounts with virtual hosts. If you do not have a virtual host and would like to get one please see the Virtual Host Name Service.

You can redirect a tilde URL, such as to the virtual host name associated with the account by using an .htaccess with this code:

Note: www alias also redirects to the virtual host.
For example, would redirect to
If you want to remove this redirect, you can simply remove "[OR]" from line 2 and all of line 3.

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/~account/ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [R,L] 

After you've setup a redirect, you should test it by going to the tilde URL.

You can also redirect users using Meta tag http-equiv refresh. For instructions, see Using the Meta Tag "Refresh" to Redirect to a Different URL.

Redirecting from to

If you are looking to redirect from to, you can set up the following in your .htaccess file.

RewriteEngine on
# remove trailing slash
RewriteRule (.+)/$ /~account/$1 [L,R=301]

# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ /~account/$1/ [L,R=301]

# perform redirect if
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Replace the 3 occurrences of ~account with the name of the actual account.

Redirecting HTTP to HTTPS

Include a .htaccess file with the following rules in your www folder in order to direct incoming traffic from HTTP to HTTPS:

RewriteEngine On
RewriteCond %{HTTPS} !on$
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]