
Redirects tell your web server to automatically send visitors from one URL to another. They are essential whenever you move pages, rename URLs, launch a new domain, or retire old content. DirectAdmin provides a built-in redirect tool so you can set this up without editing configuration files manually. This guide shows you exactly how.
What Are Site Redirects and Why Use Them?
A site redirect is an instruction that says: "when someone visits URL A, send them to URL B instead." Common use cases include:
- Moving a page to a new URL after a site redesign
- Redirecting an old domain to a new one after rebranding
- Sending
http://visitors tohttps://(though this is usually handled by SSL configuration) - Consolidating duplicate content by redirecting variants to a single canonical URL
- Pointing a product page that no longer exists to the category page instead
301 vs. 302 — Which Redirect Type Should You Use?
301 — Permanent Redirect
A 301 tells browsers and search engines that the move is permanent. The old URL will not come back. Search engines transfer nearly all of the original page's SEO authority (link equity) to the new URL. Use a 301 whenever a page has genuinely moved for good — this is the correct choice for the vast majority of redirects.
302 — Temporary Redirect
A 302 tells browsers and search engines that the move is only temporary and the original URL will eventually return. Search engines keep the original URL in their index and do not transfer SEO authority. Use a 302 only for short-term situations, such as sending visitors to a maintenance page while you update the site, or running a time-limited A/B test.
SEO Tip: Use 301 (Permanent) for any URL that has moved permanently. This ensures search engines update their index and preserves the ranking authority of the original page. Using 302 by mistake on a permanent move will cause you to lose SEO value over time.
How to Create a Redirect in DirectAdmin
- Log in to your DirectAdmin control panel.
- Navigate to Advanced Features → Site Redirects (the exact label may vary slightly by DirectAdmin version).
- Click Add New Redirect.
- In the Source URL field, enter the path you want to redirect from. This is the path on your domain (e.g.,
/old-pageor just/for the whole domain). - In the Destination URL field, enter the full destination URL including
https://(e.g.,https://www.example.com/new-page). - Select the redirect type: 301 Permanent or 302 Temporary.
- Click Save or Add to activate the redirect.
Redirect an Entire Domain
To redirect all traffic from one domain to another (for example after a domain change), set the Source URL to / (the root) and the Destination URL to the new domain with https://. Use 301 Permanent. This sends every visitor who types the old domain to the homepage of the new domain.
Redirect a Specific Path
To redirect only a specific page or subfolder, enter the exact path in the Source field. For example:
- Source:
/services/old-name→ Destination:https://www.example.com/services/new-name - Source:
/blog/2020/old-post→ Destination:https://www.example.com/blog/updated-post
Path-specific redirects only affect matching URLs — the rest of your site continues to work normally.
How to Verify That Your Redirect Is Working
After saving a redirect, test it using one of these methods:
- Browser test: Visit the source URL in a private/incognito window. The browser should automatically load the destination URL.
- Online redirect checker: Use a free tool such as
redirect-checker.orgorhttpstatus.ioto confirm the HTTP status code is 301 or 302 as expected. - Developer tools: Open your browser's Network tab (F12), navigate to the source URL, and look for the 301 or 302 response in the request log.
Note: Browser caching can make it look like a redirect is not working if you have visited the URL before. Always test in a private/incognito window or clear your browser cache before concluding there is a problem.
307 and 308 Redirects — When Do They Matter?
Beyond 301 and 302, there are two more redirect status codes that developers working with APIs and form submissions should know about.
307 Temporary Redirect
Like 302, a 307 signals a temporary move. The critical difference is that 307 strictly forbids the browser from changing the HTTP method. If a client sends a POST request to a URL that returns 307, the client must send another POST to the new location — not convert it to a GET. This matters for API endpoints and form handlers where the original request method must be preserved.
308 Permanent Redirect
Like 301, a 308 signals a permanent move and instructs search engines to update their index. It also preserves the HTTP method, making it the equivalent of 301 for non-GET requests in REST APIs. For standard websites that use only GET requests for page navigation, 301 and 302 remain the correct choices. 307 and 308 are for developers building APIs where method integrity across redirects matters.
Wildcard Domain Redirect Using .htaccess
When you change your domain name, you need every single page on the old domain to redirect to the corresponding page on the new domain. Setting up individual redirects for hundreds of pages is impractical. The correct approach is a wildcard redirect that captures the full URL path and appends it to the new domain automatically.
Add the following to the .htaccess file in the root of your old domain:
RewriteEngine OnRewriteCond %{HTTP_HOST} ^old-domain\.com$ [NC]RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]
The $1 placeholder captures everything after the domain root and appends it to the destination, so old-domain.com/services/web-hosting redirects to new-domain.com/services/web-hosting rather than just the homepage. Keep the old domain active and renewed for at least one to two years after the switch to ensure the redirects continue to function and all SEO authority is fully transferred.
Diagnosing and Fixing Redirect Loops
A redirect loop occurs when URL A redirects to URL B and URL B redirects back to URL A — or through a longer chain that eventually cycles back to the starting URL. The browser aborts with an error such as "ERR_TOO_MANY_REDIRECTS" or "This page isn't working — too many redirects." Visitors cannot access the site at all until the loop is resolved.
Trace the Chain with curl
The fastest diagnostic tool is curl -IL from a terminal or command prompt:
curl -IL https://example.com/page— prints all response headers for each hop in the redirect chain- Each
Location:header shows where that hop points next - A healthy chain ends with HTTP 200; a loop never resolves and eventually times out
Common Causes and Fixes
- Self-referencing rule: A redirect whose source and destination are the same URL. Review each
RedirectandRewriteRuleline in.htaccessand remove the self-referencing one. - Double HTTPS redirect: The server config (e.g., Nginx or Apache virtual host) already forces HTTPS, and the
.htaccessadds a second HTTPS redirect on top of it. Remove the duplicate.htaccessrule. - Two domains redirecting to each other: Domain A redirects to domain B, but domain B's
.htaccesscontains a rule that redirects back to domain A. Check the destination domain's.htaccessand remove the conflicting rule. - Plugin conflicts in CMS: A WordPress redirect plugin or SEO plugin may add redirect rules that conflict with
.htaccess. Disable plugins temporarily to isolate the cause, then fix the conflicting setting.
After any fix, always clear your browser cache and retest using curl -IL or an online redirect checker to confirm the chain terminates cleanly at HTTP 200.
Summary
- Use 301 for all permanent moves — it preserves SEO rankings.
- Use 302 only for genuinely temporary situations.
- Redirects can apply to a whole domain (source:
/) or a specific path. - Use a wildcard
RewriteRulewith$1to redirect an entire domain while preserving URL paths. - Debug redirect loops with
curl -ILand fix conflicting rules in.htaccess. - Always test with a private browser window or an online redirect checker after setting up.
Full Control of Your Website
AsiaGB hosting includes DirectAdmin with built-in redirect management, SSL, and everything you need to run a professional website.
View Hosting Plans