Categories
Knowledge base

How to Redirect Domains in DirectAdmin

Redirecting a domain is a common practice when you need to forward traffic from one domain to another. DirectAdmin provides two main methods for setting up domain redirections: the built-in redirect tool and using .htaccess rules. This guide will help you understand both methods and choose the best one for your needs.

Why Redirect a Domain?

There are several reasons why you may want to set up a redirect:

  • Website Migration: Forward traffic from an old domain to a new one.
  • SEO Benefits: Preserve search engine rankings when changing URLs.
  • HTTPS Enforcement: Redirect non-secure HTTP traffic to HTTPS.
  • Multiple Domain Usage: Direct users from multiple domains to a single website.

Method 1: Using the Built-in Redirect Tool in DirectAdmin

DirectAdmin includes an easy-to-use tool for setting up redirects.

Step 1: Log in to DirectAdmin

  1. Open your web browser and go to your DirectAdmin login page.
  2. Enter your username and password, then click Login.

Step 2: Navigate to the Redirects Section

  1. Click on Account Manager > Site Redirection.
  2. Click Create New Redirect.

Step 3: Set Up the Redirect

  1. Enter the source URL (e.g., your old domain or page path).
  2. Enter the destination URL (e.g., the new domain or page you want traffic redirected to).
  3. Choose the type of redirect:
    • 301 (Permanent Redirect): Recommended for SEO and permanent domain changes.
    • 302 (Temporary Redirect): Use this for short-term redirections.
  4. Click Save to apply the redirect.

Method 2: Redirecting via .htaccess File

For more advanced control over redirections, you can use the .htaccess file.

Step 1: Access Your File Manager or FTP

  1. Navigate to File Manager in DirectAdmin.
  2. Open the root folder of your domain (e.g., public_html).
  3. Locate or create a file named .htaccess.

Step 2: Add Redirect Rules to .htaccess

Use the appropriate rule based on your redirection needs:

Redirect an Entire Domain

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301]

Redirect a Specific Page

Redirect 301 /oldpage.html https://yourdomain.com/newpage.html

Redirect Non-WWW to WWW

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]

Redirect HTTP to HTTPS

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

Step 3: Save and Test

  • Save the .htaccess file and refresh your website.
  • Test the redirect by entering the old URL in a browser.
  • Use an online redirect checker to verify your setup.

Common Issues and Troubleshooting

Redirect Not Working?

  • Ensure that the .htaccess file is placed in the correct folder (public_html).
  • Clear browser cache or test in an incognito window.
  • Check for conflicting redirect rules.

Redirect Loop or Error?

  • Make sure you’re not redirecting a domain to itself.
  • Avoid using both DirectAdmin’s redirect tool and .htaccess at the same time for the same rule.
  • Remove unnecessary rules and test again.

Conclusion

Setting up domain redirects in DirectAdmin is easy using either the built-in redirect tool or .htaccess file. Choose the method that best fits your needs and follow the steps outlined in this guide to ensure a smooth and effective redirection.

For more hosting and domain management tips, visit xldomein.com!

Calendar

March 2025
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Categories