Skip to content
search-engine-optimizedby Netsolution
  1. Home
  2. Files and configuration
  3. Htaccess Redirect Generator

Htaccess Redirect Generator

Produce your redirect rules without risking a 500 error across the whole site.

Locally generated Apache directives, compatible with LiteSpeed. Nothing is stored. No usage limit.

What this tool is for

The .htaccess file lets you configure the server from a plain text file placed at the root. Its most common use is redirection: telling the server that an address has moved.

It is indispensable during a rebuild. With no redirect plan, every old address becomes a 404, and everything those pages had accumulated with Google is lost. With correct 301s, the signal is transferred in full.

The syntax is strict and unforgiving. A malformed directive does not produce a warning: it produces a 500 error across the entire site, home page included. This generator rules out syntax faults and orders the rules correctly.

Before any change: download a copy of your current .htaccess. If something goes wrong, restoring takes ten seconds; with no copy, reconstructing it can take hours.

How to read the results

The order of the rules is decisive. Apache applies them in sequence, and the generator puts the precise mappings before the general rules. A broad rule at the top of the file absorbs the URLs your fine-grained rules were meant to handle.

Forcing HTTPS goes first, so that every other rule already applies on a secure connection and does not add an extra hop.

The www normalisation comes next. It has to be combined with the HTTPS forcing in a single rule, otherwise some addresses go through two successive redirects instead of one.

The individual mappings come last. Each handles one specific address. After deploying, check a sample with the redirect checker to confirm no chain has formed.

The L flag means “last rule”: it stops processing as soon as a match is found. Its absence produces unexpected chaining.

Common mistakes

Deploying with no backup. A syntax error makes the site unreachable instantly. With no copy of the previous file, recovery takes far longer than the outage.

Redirecting en masse to the home page. The easy way out for handling hundreds of old URLs, treated by Google as a disguised error and ignored. Redirect to equivalent content, or return a plain 404.

Creating redirect chains. An old address redirected to another that is itself redirected adds a pointless hop. Always connect the origin to the final destination.

Stacking rules across migrations. After three rebuilds the file reaches hundreds of lines, reread on every request. A periodic review is called for.

Forgetting to test after deploying. A rule written is not a rule that works. Test a sample of real addresses, particularly the deep pages — where the rules most often fail.

Going further

Frequently asked questions

Where does the .htaccess file go?

At the root of the site, generally in public_html or www. It applies to the folder containing it and to all its subfolders. The name starts with a dot, which makes it hidden by default: remember to switch on hidden files in your file manager.

Can a mistake break the whole site?

Yes, immediately and completely. A badly written directive produces a 500 error across the whole site, home page included. That is why you always keep a copy of the file before changing it, and test straight afterwards.

301 or 302?

301 for a permanent move: Google transfers the signal and deindexes the old address. 302 only for a genuinely temporary detour, such as a maintenance page. Using a 302 on a permanent migration is the most expensive mistake in search.

In what order should the rules go?

Specific rules before general ones. Apache applies directives in order, and a broad rule placed first will absorb the URLs your precise rules were meant to handle. It is the most frequent cause of error in large files.

Do I have to choose between www and non-www?

You have to choose, and redirect the other. Serving the same content on both addresses creates duplication and splits your signals. Either one is fine, the only wrong answer is not deciding.

How many rules can a .htaccess hold?

Technically thousands, but the file is reread on every request: past a few hundred rules, performance degrades. For a large migration, a mapping table handled by the application beats a two-thousand-line file.