Guides Guides 5 min read 909 words

Redirect an Expired Domain Using .htaccess (301)

A short 301 rule in the .htaccess file sends visitors from an expired domain you own to another site. Rules, steps and testing for Apache hosting.

To redirect an expired domain with .htaccess, host the domain on an Apache server, put a 301 rule in the .htaccess file in its web root, and test the result. The file only works on Apache-compatible servers with overrides enabled, so it is not an option if the domain has no hosting. In that case use the Cloudflare redirect method instead.

What .htaccess is and when it works

Apache describes .htaccess files as a way to make configuration changes on a per-directory basis. A file with one or more directives applies to its directory and all subdirectories. Which directives are honoured depends on the server's AllowOverride setting. Its default value is None, which means .htaccess files are ignored unless the host enables them for the directory. Shared hosting and control panels such as cPanel typically enable them, but if your rule does nothing, ask your host whether overrides are on. Our guide what is the .htaccess file has the basics.

Apache itself recommends putting rules in the main server configuration when you have access to it. Most people redirecting a single expired domain do not, so .htaccess is the practical way.

Before you start

  • You own the domain and have hosting for it on Apache (or a compatible server such as LiteSpeed), with its nameservers or DNS pointing to that hosting.
  • You have FTP/SFTP access or the host's file manager.
  • You know the exact URL of the target site, for example https://newdomain.com.
Explanatory diagram: The old URL is requested: The request reaches your Apache server.. A redirect rule matches: Apache returns an HTTP redirect.. The browser follows it: The destination receives a new request.
Explanatory illustration, not a current dashboard screenshot or configuration test. Based on official documentation checked 13 November 2026: https://httpd.apache.org/docs/2.4/rewrite/remapping.html

Step by step

  1. Connect to the server. Use an FTP client such as FileZilla, or your host's file manager, with the host, username and password your hosting company provided.
  2. Open the web root of the expired domain. On many hosts this is public_html, but the name varies. Look for an existing .htaccess file. It may be hidden, so enable "show hidden files" in your client.
  3. Back up the existing file. Download .htaccess to your computer and keep an untouched copy. If the domain runs WordPress, the file contains WordPress rules, and deleting them breaks the site. For a domain that only redirects, that no longer matters.
  4. Add the redirect rule from one of the options below. Replace newdomain.com with your target.
  5. Upload the file back to the same folder, overwriting the old one, and test.

Use a plain text editor (Notepad, TextEdit in plain-text mode, VS Code). A word processor can add formatting characters that break the file.

The rules

Option 1: redirect everything, keep the path

This sends olddomain.com/page to newdomain.com/page:

RewriteEngine On
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301]

It needs mod_rewrite. R=301 makes the redirect permanent and L stops processing further rules. Our earlier version of this guide also used the NC flag (case-insensitive match); it is not needed here because the pattern ^(.*)$ matches any text.

Option 2: redirect everything to one page

Use this when the new site does not have matching URLs, so the old paths would otherwise lead to 404 errors:

RewriteEngine On
RewriteRule ^ https://newdomain.com/ [L,R=301]

Option 3: the simpler mod_alias form

Google's documentation shows the mod_alias form for simple permanent redirects. It keeps the rest of the path automatically:

Redirect permanent / https://newdomain.com/

Apache's docs recommend Redirect over mod_rewrite where a simple redirect is enough. Try this first, and fall back to the rewrite rules if your host rejects it.

Test the redirect

  • Open the old domain in a private browser window. A cached 301 can mislead browser tests. Use curl to inspect the current server response rather than relying on a private window alone.
  • Or run curl -I https://olddomain.com/ and check for 301 and the Location header.
  • Test both the bare domain and the www version, and one deeper URL if you used option 1.

If it does not work

  • 500 error after saving: there is a syntax error in the file, or a directive is not allowed. Apache's troubleshooting section says the error log will name the problem. Restore your backup and check for typos.
  • Nothing happens: AllowOverride is probably set to None, or the domain does not point to this hosting yet. Check DNS first (see what is DNS).
  • Redirect loop: the target must not resolve back to the old domain.
  • HTTPS warning on the old domain: a redirect from https://olddomain.com needs a valid certificate on the old domain, or browsers show a warning before the redirect happens. Many hosts offer free certificates.

301 vs 302 and SEO expectations

Google treats permanent server-side redirects (301, 308) as a signal that the target should be canonical, and temporary ones (302, 307) as a signal to keep the source in search results. For a permanent move use 301. Our .htaccess 301 redirect guide covers single pages and other cases.

A redirect does not guarantee that old links or rankings carry over. Google's spam policies call out expired domain abuse: buying an expired domain and repurposing it mainly to manipulate rankings with content that gives users little value. Redirecting to a closely related site is a normal use; redirecting to something unrelated is the risky one. Read do expired domains still work? and how to transfer ownership if you are still getting set up.

Sources

Still checking whether you control the name? Use our WHOIS lookup to inspect its current registration status before configuring hosting.