Learn how to enable or disable redirection for domain aliases in cPanel. Follow these step-by-step instructions to efficiently manage domain alias redirection, ensuring optimal website functionality and user experience.
Ever purchased a new domain name but want visitors to your original website? Domain alias redirection allows website owners to direct traffic from one domain alias to another URL. Understanding how to enable or disable redirection is essential for managing website traffic effectively and maintaining a seamless user experience. This guide will equip you, whether you're a website-building beginner or a seasoned pro, with the knowledge to enable or disable domain alias redirection within your cPanel interface.
Understanding Redirection: A Traffic Light Analogy
Enabling or disabling domain alias redirection enables website owners to control how traffic is directed between domain aliases. Think of a website redirection like a traffic light. When a visitor types in your domain alias (like "greenlight.net"), cPanel acts as the traffic light, instructing their browser (the car) to redirect them to your main website (greenlight.com). This ensures visitors land where you want them, even if they don't know your primary domain name.
Why Use Redirection? Common Scenarios
Here are some common reasons why website owners use domain alias redirection:
- You purchased a new domain name that's easier to remember than your original one.
- You're running a seasonal promotion with a unique domain name, but want visitors to eventually go to your main website.
- You have a typo-squatted domain (a domain similar to yours with a misspelling) and want to redirect visitors who accidentally typed in the wrong address.
Types of Redirection: Temporary vs. Permanent
There are two main types of redirection:
-
Permanent (301 Redirect): This tells search engines (like Google) that your alias has permanently moved to a new location. The search engine will update its records to reflect this change.
-
Temporary (302 Redirect): This is useful for situations where you might have a temporary page under construction on your main site. You can use a 302 redirect to send visitors to a different, temporary webpage until your main site is ready.
Redirect Examples
Scenario | Code |
---|---|
Redirect the entire site to a new domain
|
Redirect 301 / http://example_domain.com/ |
Redirect a page to a different page on the same domain
|
Redirect 301 /original.html http://www.example_domain.com/new.html |
Redirect the entire directory to a different directory on the same domain
|
Redirect 301 /old-directory http://www.example_domain.com/new-directory |
Temporarily redirect the entire site to a new domain
|
Redirect 302 / http://example_domain.com/ |
Temporarily redirect a page to a different page on the same domain
|
Redirect 302 /original.html http://www.example_domain.com/new.html |
Temporarily redirect the entire directory to a different directory on the same domain
|
Redirect 302 /old-directory http://www.example_domain.com/new-directory |
Step-by-Step Guide
The following steps will guide you through enabling or disabling redirection for a domain alias in cPanel:
-
Log in to cPanel and navigate to the "Domains" section. You will see all your domains listed.
-
Find the alias you want to manage and click on "Redirects To".
-
Enabling Redirection: If the listed domain redirects to a different domain, the destination will appear here. If the redirection is currently disabled, and you want to manage the alias redirect, step back to cPanel » Home » Domains » Redirects.
-
When you get there, enter the destination URL (specifying a protocol in this text box. For example, https://, or ftp://.) to which you want to redirect the domain alias.
6. Choose Your Redirection Preference:
- Redirect with www.: This option redirects only visitors who type the "www." prefix before the domain name in the URL (e.g., www.example_domain.com redirects to example_domain.com).
- Redirect with or without www.: This option redirects all visitors, regardless of whether they include the "www." prefix in the URL (both example_domain.com and www.example_domain.com redirect to the chosen destination).
- Do Not Redirect www.: This option leaves URLs with the "www." prefix unchanged (e.g., www.example_domain.com remains www.example_domain.com).
7. Wildcard Redirect (Optional):
Enable this option if you want all files within a directory to redirect to the same filename in the new directory.
For example, if you redirect example1.com to example_domain.com with Wildcard Redirect enabled, then accessing http://example1.com/pic.jpg will redirect to http://example_domain.com/pic.jpg. This ensures all files within the example1.com directory redirect to their corresponding files in the example_domain.com directory.
8. Add the Redirect:
Click the "Add" button to confirm your chosen settings and create the redirect.
Redirecting Domains Using cPanel API: A Step-by-Step Guide
While the cPanel interface offers a convenient way to create redirects, the cPanel API provides a powerful alternative for programmatic control over redirection.
Here's how to manage redirects using cPanel API commands:
1. Prerequisites:
- API Access: Ensure you have API access enabled within your cPanel account.
- API Tool: You'll need a tool for executing API commands, such as the cPanel UAPI utility or a programming language library that supports cPanel API interactions.
2. Retrieving Existing Redirects:
- List Existing Redirects: To view a list of redirects already configured in your account's .htaccess files, use the following command:
uapi --output=jsonpretty Mime list_redirects
- Get Redirect URL: To retrieve the specific redirect URL associated with a domain, use:
uapi --output=jsonpretty Mime get_redirect domain='example_domain.com'
3. Creating a Redirect:
- Add Redirect: To create a new redirect, issue this command:
uapi --output=jsonpretty Mime add_redirect domain='example_domain.com' redirect='http://example_domain.com/'
4. Removing a Redirect:
- Delete Redirect: To remove an existing redirect, use:
uapi --output=jsonpretty Mime delete_redirect domain='example_domain.com'
Key Considerations:
- Domain Name: Replace
example_domain.com
with the actual domain you want to redirect. - Redirect URL: Specify the full destination URL for the redirect.
- Output Format: The
--output=jsonpretty
option presents the API response in a readable JSON format. - Documentation: Refer to the official cPanel API documentation for detailed command usage and options.
Testing Your Redirect:
The "Directory" column in the "Current Redirects" table displays a link.
Clicking this link will test your redirect. If configured correctly, you should be directed to the original domain (e.g., clicking the link for a redirect from example1.com should take you to example_domain.com).
Label | Description |
---|---|
Domain
|
The domain to redirect. ALL represents all of the account’s publicly available domains. |
Directory
|
The directory to redirect. Click the link to test the redirection. |
Regular Expression
|
The system will redirect any URL that matches the regular expression in this column. |
Redirect URL
|
The URL to which you wish to redirect users. |
HTTP Status Code
|
The numerical HTTP Status Code of the redirect. |
Type
|
- permanent: This setting notifies the visitor's browser to update its records. - temporary: This setting does not update the visitor’s bookmarks. |
Match www.
|
Only redirect visitors who enter the www. prefix before the domain name part of the URL. |
Wildcard
|
Redirect all files within a directory to the same filename in the new directory. For example, if you enable the Wild Card Redirect setting and example1.com redirects to example_domain.com, then a visitor who tries to access the http://example_domain-1.com/pic.jpg URL redirects to the http://example_domain.com/pic.jpg URL. |
Actions
|
Available actions for the redirection: - Delete: Delete the redirection. Click Yes to confirm the deletion. |
Important: Most web browsers add redirections to a cache. Visitors may need to clear their web browser cache to remove the redirection from their web browsers.
Redirects via Third-Party Applications:
-
Third-party applications or content management systems (like WordPress) might have their built-in redirection functionality. Using these methods can override cPanel's redirection settings.
-
Be sure to choose the appropriate redirection type (permanent or temporary) based on your specific needs.
WebHostingM Support
Remember: If you ever encounter issues or have questions specific to your WebHostingM account, or encounter any challenges that require assistance, simply submit a ticket and our friendly engineers will be happy to help you resolve any challenges you may face.
Not a WebHostingM customer yet, but curious about the power of cPanel? WebHostingM offers fantastic cPanel hosting plans – check them out at our cPanel Marketplace and unlock a world of website management possibilities!