https://help.superhosting.bg/en/cpanel-redirects-301-302.html
  • bg
  • en

Hosting, Domains, Cloud, Virtual Private Servers (VPS), Managed VPS, SSL Certificates

Setting up Redirects in cPanel

Control Panel cPanel
cpanel redirect, cpanel redirects, domain redirect

Тhe Redirects interface allows you to redirect all domains in cPanel and their internal resources to other domains and URLs. A Redirect sends all domain visitors (and search engine bots) to a different URL.

A URL is the domain along with the web resources after its name, e.g. http://sourcedomain.com/site/address.php

There are two types of redirects - 301 Permanent and 302 Temporary.

info-icon All redirects through the cPanel interface are leaving a piece of code in the .htaccess file.

Add Redirect

Add the source domain (sourcedomain.com) to cPanel (as addon or parked domain) with your account’s main domain name servers.

The target domain (targetdomain.com) does not necessarily have to be in cPanel or to be with your account’s main domain name servers.

Creating a redirection in cPanel - selecting the type of redirection(1Type: Select the redirect type - permanent 301 or temporary 302. In most cases it is better to choose a permanent redirect 301.

Select a redirect 302 if it is really going to be temporary, for example, in cases when maintenance is performed or access to the web source is temporarily restricted.

301 Moved Permanently and 302 Found are HTTP status codes received in response to web clients and search engines bots trying to access the redirected URL.

info-icon A 301 Moved Permanently status code will notify the visitor’s browser to update its bookmarks with the new URL. It will also notify the bots that the requested web resource has a new URL.

Choose a domain name that will be redirected

(2http://(www.)?: Select a source domain from the drop-down menu to set up a redirect.

If you keep the **All Public Domains* option in this field, all domains on the account will be redirected.

Whether you want to redirect specific directory / file or just the domain

(3/: To redirect only this domain, leave the field empty. For example, if you wish to redirect only sourcedomain.com without its internal URLs such as sourcedomain.com/dir/file.html.

If you redirect a directory/file or URL, they will be separately redirected. For example, if users access http://sourcedomain.com, they will not be redirected.

Enter the target of redirection - to what web address the visitors will be directed(4Redirects to: This is the target domain.

You must specify a protocol in this text box. For example, http://, https:// or ftp://.

Enter a URL where visitors will be redirected:
- a domain or
- directory URL, e.g. http://targetdomain.com/directory or
- file URL, e.g. http://targetdomain.com/directory/file.html

The target domain address will be displayed in the address bar after redirection.

Whether redirection is valid when entering the domain with or without the www in front(5www. redirection: This option refers to the source domain that will be redirected (sourcedomain.com).

• Only redirect with www. - Redirect is active only for the URL with the www. prefix before the domain name part. e.g. www.sourcedomain.com.

• Redirect with or without www. - Redirect is active for both URLs with or without the www. prefix before the domain name part, e.g. www.sourcedomain.com or sourcedomain.com.

• Do not redirect www. - Redirect is active only for the URL without www. prefix before the domain name part, e.g. sourcedomain.com. This option is suitable for setting up a redirect, beginning with www. prefix, e.g. sourcedomain.com will be always redirected to www.sourcedomain.com.

Wildcard redirect(6Wildcard redirect: Select the Wildcard Redirect option if you wish to redirect all files within a directory to the same filename in the new directory.

The Wildcard option basically redirects everything after the source domain name and it is added to the new URL. For example, when accessing:

http://sourcedomain.com/dir/index.html

users will be redirected to the same resource, but with the new domain:

http://targetdomain.com/dir/index.html

WordPress, Joomla!, Drupal

When redirecting through cPanel-> Redirects, the system adds the redirect code to the end of the .htaccess file. Some content management systems such as WordPress, Joomla! or Drupal might not be able to handle that code. This is due to the fact that the application follows the rules from a specific section of the .htaccess file. This section is always before the redirecting code.

For example the WordPress rules are in the following .htaccess file sector:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

In case redirect fails, move the rules to the beginning of the WordPress section, after the RewriteEngine On line, for example:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sh\-mywordpress\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sh\-mywordpress\.com$
RewriteRule ^dir$ "http\:\/\/targetdomain\.com\/" [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
info-icon Important: Always make a backup copy before editing the .htaccess file. Also, if there are content irregularities in the .htaccess file, the website might stop loading and you can get an Error 500 message.

Current Redirects

In this section you might check all available redirects.

Active redirects in cPanel

Editing of the redirects is not supported. To modify a redirect, you must delete it, and then recreate it.

You can search the redirects by domain, URL, etc.

To check if a redirect works properly, click on the respective link in the Directory column.

500px270px
SuperHosting.BG

Comments

Be the First to Comment!

Notify of
avatar
wpDiscuz
All rights reserved © 2005-2017 , www.superhosting.bg