Knowledge Base

Setting up redirects

A redirect sends visitors from one address to another, for example from an old page to a new one or from one domain to another.

Choosing the type of redirect

Type When to use it
301 (permanent) The page or website has moved for good. Search engines pass the old address's ranking to the new one.
302 (temporary) The move is only for a short time, such as during maintenance.

Adding a redirect in DirectAdmin

  1. Log in to DirectAdmin.
  2. Go to Account Manager and click Site Redirection.
  3. If you have more than one domain, choose the domain.
  4. Enter the local path to redirect from, such as /old-page. Enter / to redirect the whole domain.
  5. Choose the redirect type, usually 301.
  6. Enter the full destination address, such as https://yourdomain.com/new-page.
  7. Create the redirect.

Adding a redirect with .htaccess

For more control, add redirect rules to the .htaccess file in your website's public_html folder, using File Manager. For example, to redirect a single page:

Redirect 301 /old-page https://yourdomain.com/new-page

To send all visitors from www.yourdomain.com to yourdomain.com:

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

If your website uses WordPress, add your rules above the # BEGIN WordPress line. Always download a copy of .htaccess before editing it. A mistake in this file can take your website offline.

To send all visitors to https://, see Forcing HTTPS on your website.

Please rate this article to help us improve our Knowledge Base.

0 0