How to Redirect a Page or Website Using .htaccess

When a page moves or a whole site changes address, a redirect sends visitors (and search engines) straight to the new location instead of showing a broken link or a 404 error. On Apache-based Noiz hosting you set redirects in a .htaccess file placed in your site's document root. This guide shows you how to redirect a single page, a page to another domain, and an entire website, and it clears up a common mistake that stops redirects from behaving as expected.

Last reviewed: 27 July 2026, against Apache httpd 2.4 (current stable series). This guide is written for Noiz hosting and is kept current against Apache. It complements, and does not replace, the official Apache documentation linked below.

Official Documentation Reference

Prerequisites

  • A hosting plan served by Apache (all Noiz shared and reseller plans qualify).
  • Access to your site's files through your control panel's File Manager, or over FTP/SFTP.
  • The redirect rules go in a file named exactly .htaccess (note the leading dot, no file extension) in the folder you want to affect, usually your document root.

Two ways to redirect, and why one line trips people up

Apache offers two separate modules that can perform redirects, and mixing their directives is the single most common cause of confusion:

  • mod_alias provides the simple Redirect and RedirectMatch directives. Use these for straightforward "this address goes to that address" rules. They do not need RewriteEngine on.
  • mod_rewrite provides RewriteRule and RewriteCond for pattern-based, conditional rewriting. These do require RewriteEngine on to be switched on first.

Older guides often show RewriteEngine on sitting above a Redirect 301 line. That line belongs to mod_rewrite and has no effect on a mod_alias Redirect. It is harmless clutter, but it misleads readers into thinking the two must go together. For a plain Redirect, leave RewriteEngine on out.

Redirect one page to another page on the same site

Add this to the .htaccess in your document root:

# Redirect a single page to another page on the same site
Redirect 301 /oldpage.html /newpage.html

Now opening yourdomain.com/oldpage.html sends the visitor to yourdomain.com/newpage.html. The first path is the old location and must start with a /; the second is where you want visitors to land.

Redirect a page to another domain

# Redirect a single page to a different domain
Redirect 301 /mypage.html https://example.com/

Always write the target as a full https:// URL when it points to another site. Serve the secure address, not http://: every Noiz plan includes a free SSL certificate, so pointing visitors at the plaintext version only adds an extra hop and a security warning risk. Replace example.com with the real destination.

Redirect an entire website to a new domain

To move a whole site while keeping the rest of each address intact, one mod_alias line is enough. Apache appends whatever followed the matched prefix, so paths carry across automatically:

# Redirect every request to a new domain, preserving the path
Redirect 301 / https://newdomain.com/

A request for olddomain.com/blog/post-1 then lands on newdomain.com/blog/post-1. Place this rule only in the old site's .htaccess. Do not add it to the new domain's document root, or you will create a redirect loop.

Permanent (301) versus temporary (302)

The number after Redirect is the HTTP status code:

  • 301 means "moved permanently". Search engines transfer ranking to the new address, and browsers cache the redirect aggressively. Use it once the move is final.
  • 302 means "found / moved temporarily". Nothing is cached long term and search rankings stay with the original address. Use it for short-lived redirects, or while you test.

Because browsers cache a 301 hard, test a new rule with 302 first. If you publish a wrong 301 and then fix it, your own browser may keep following the old target until you clear its cache or test in a private window.

Matching a page exactly

The mod_alias Redirect directive matches by prefix. Redirect 301 /old /new also catches /older, /old/page and anything else starting with /old, which is often a surprise. When you need to match one exact path and nothing else, use RedirectMatch with an anchored expression:

# Match /oldpage.html exactly and nothing else
RedirectMatch 301 ^/oldpage\.html$ /newpage.html

When you genuinely need mod_rewrite

Reach for mod_rewrite only when a simple Redirect cannot express the rule, for example redirecting based on query strings, hostnames or conditions. This is the case where RewriteEngine on is required:

# Redirect an entire domain with mod_rewrite (path preserved)
RewriteEngine on
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]

Here RewriteEngine on switches the module on, R=301 issues a permanent redirect, and L stops rule processing at that point. For plain address-to-address moves the mod_alias examples above are simpler and easier to maintain.

Troubleshooting

  • The redirect does not happen: confirm the file is named exactly .htaccess and sits in the correct folder. Some File Managers hide dotfiles, so enable "show hidden files".
  • Old target keeps loading after you fixed a 301: your browser cached the permanent redirect. Clear the cache or retest in a private window.
  • "Too many redirects" error: a rule is pointing a site at itself, or the same rule exists on both the old and new domain. Remove the redirect from the destination.
  • 500 Internal Server Error after editing: a typo in the .htaccess syntax. Undo the last change and add rules back one at a time. No server restart is needed, as Apache reads .htaccess on every request.

If a redirect will not take effect or you would rather Noiz set it up for you, contact Noiz support with your domain and the old and new addresses, and the team will apply it for you.

  • 0 Users Found This Useful
  • domain, htaccess, redirect, apache
Was this answer helpful?

Related Articles

How to Create a User-Friendly URL Using htaccess

A long, folder-heavy web address such as example.com/files/folder/sitemap.html is hard to...

How to Create User-Friendly URLs Using .htaccess

A user-friendly URL (sometimes called a clean, pretty, or search-engine-friendly URL) is a short,...

How to Redirect a Page to Another Page or Website Using .htaccess

When a page on your website moves or is retired, sending visitors and search engines to the...

How to Block an IP Address Using .htaccess

An .htaccess file lets you block a single IP address, a range of addresses, or an entire network...