How can I Redirect URLs in cPanel

Login your cpanel

1. Click the Redirects button on the front page under the “domains”

2. Enter the address of the web page to move in the first field.

3. Enter the redirection address in the second field. (this can be a sub domain
and may be listed as a directory on home page).

4. Choose one of the following options in the list:
*Temporary or *permanent

5. Click the Add button.

Redirect URLs in cPanel Servers

Redirect Examples using .htaccess

To redirect an entire site to a new domain:

Redirect 301 /

The following performs a 301 redirect based on the clients IP address, this could be used for banning IP addresses.

Banning an IP Address using ReWrite

RewriteCond %{REMOTE_ADDR} ^(A\.B\.C\.D)$
RewriteRule ^/* [L]

To redirect a folder and all of the pages or files contained within it to another page or domain.

RewriteEngine On
RewriteRule ^foldername/* [R=301,L]

Domain redirect

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Image Hotlink protection and redirect

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourdomain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ [L]

PHP 301 Redirect

Insert the following in your index page.

header("HTTP/1.1 301 Moved Permanently");

ASP 301 Redirect

Response.Status="301 Moved Permanently"


Force SSL/https redirect

Redirect the user to secure connection (https://) can be accomplished with a .htaccess file containing the following lines:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]

In case you wish to force HTTPS for a particular folder you can use:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$$1 [R,L]

The .htaccess file should be placed in the folder where you need to force HTTPS.


HTML Redirect

<meta http-equiv="refresh" content="0;url=">
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

cPanel & WHM Version 74 Now in STABLE

cPanel has released cPanel & WHM Version 74 to the STABLE tier. It includes updates for some...

Installing cpanel on google cloud

Create a new CentOS 7 instance on your google cloud engine. From the cPanel & WHM System...

Install Free SSL Let’s Encrypt plugin in cPanel

Let’s Encrypt is a trusted, open source certificate authority that offers free SSL certificates...

Replace MySQL with Percona in cPanel Server

Percona Server is an enhanced drop-in replacement for MySQL. If you are a web hosting service...

Install nginx as a reverse proxy cPanel plugin

Install Nginx on your cPanel/WHM server using the Engintron cPanel Plugin as a reverse proxy. It...

Powered by WHMCompleteSolution