Type a tool name, for example "keyword density" or "transcript".
Select a redirect type and configure the settings to generate your .htaccess code.
Enter without www or http:// (e.g. yourdomain.com)
Use this free generator to create htaccess redirects for Apache: 301 and 302 page redirects, www and non-www, HTTPS, domain moves, directories and file extensions. Pick a redirect type, fill in a few fields, then copy or download code that is ready to paste into your .htaccess file.
.htaccess redirects are rules in a configuration file that tell an Apache web server to send visitors and search engine crawlers from one URL to another. The file is plain text, usually sits in your website's root folder, and Apache reads it on each request when your host allows overrides.
Every rule pairs a request with a response status code. A 301 says the page moved permanently, a 302 or 307 says the move is temporary, and a 410 says the page is gone for good. Google's Search Central documentation describes permanent redirects as a strong signal that the new URL should be the canonical one, and temporary redirects as a weaker signal. One typo can break an entire site, so generating the syntax from a form is safer than typing it from memory.
You can build a rule in under a minute by choosing a type, filling in its fields and generating the code. Follow these steps:
The right type depends on what changed on your site. This table shows what each of the main options does:
| Type | What it does | Typical use |
|---|---|---|
| WWW | Sends one hostname version to the other | Pick one canonical host |
| HTTPS | Sends all HTTP requests to HTTPS | After installing SSL |
| Page | Sends one old path to a new location | Renamed or removed page |
| Domain | Sends a whole domain to another | Rebrand or migration |
| Directory | Moves URLs from one folder to another | Renamed site section |
| Extension | Swaps one file extension for another | Moving .html to .php |
| Trailing Slash | Adds or removes the final slash | Consistent URL format |
Three more types are not redirects but live in the same file. Block IP denies access to the addresses you list, one per line, and accepts CIDR ranges such as 10.0.0.0/24. Hotlink stops other sites from displaying your images and allows only the domain you enter. Errors assigns custom pages (for example /errors/404.html) to 400, 401, 403, 404, 500 and 503 responses, and any field you leave empty is skipped.
A 301 redirect is a permanent move, and it is the default choice when a URL has changed for good. The Page type lets you choose from four codes:
Say your site is example.com and visitors reach it at both www.example.com and example.com, which splits links between two hostnames. Choose WWW, keep Redirect www to non-www, enter example.com and keep HTTPS checked. The tool returns three lines:
RewriteEngine OnRewriteCond %{HTTP_HOST} ^www\.example\.com [NC]RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]The condition matches any request to the www hostname, and the rule sends it to the same path on https://example.com with a 301. A request for www.example.com/pricing lands on https://example.com/pricing in a single hop.
For a Page redirect, enter /old-page as the source, https://example.com/new-page as the destination and keep 301. The result is one line, Redirect 301 /old-page https://example.com/new-page. Choose 410 instead and the line becomes Redirect 410 /old-page, which tells crawlers the page was removed.
The output is a short block of Apache directives, and each type follows the same pattern: switch the rewrite engine on, set a condition, then apply a rule with a status code. Good output is short, matches what you typed and carries the status code you expect. Review these points before pasting:
If the tool shows an error, read it literally. "Please enter a valid domain name" means the domain needs a format like example.com. A source path error means the path must start with a slash and contain no spaces or quotes. A destination error means you need a full http or https address, or a path starting with a slash.
Anyone who runs a site on Apache hosting will eventually need them. Typical situations include:
Most redirect problems come from order, duplication or a missing backup. Keep these habits:
Copy your current file before every edit. After pasting, compare the old and new versions with a code diff tool to confirm only your new lines were added. Then load the old URL in a private window and check that it lands where you expect.
Redirect the old URL straight to the final destination instead of through a middle step. If you combine rules, place the www rule above the HTTPS rule so http://www requests reach the final address in one hop. A loop, where the browser reports too many redirects, usually means two rules point at each other, or a CDN or hosting panel also forces HTTPS.
If the site returns a 500 error after you paste, remove the new lines or restore your backup first. Then check for pasted text with curly quotes, a duplicated RewriteEngine On alongside conflicting rules, or a host that does not allow overrides in .htaccess.
If you also manage cross-origin access on Apache, the CORS header generator produces rules that sit in the same file.
This generator writes rules for Apache. Nginx does not read .htaccess files and needs its own syntax, and some managed hosts restrict which directives you can use. It creates the code only; it does not read your existing file, detect conflicts with other rules or confirm that your server has the needed modules enabled. For a large migration with hundreds of old URLs, generate and test a few representative rules first, then build out the rest.
With the right type and status code, a correct redirect takes only minutes. Choose a type above, generate your code, back up your file and test the result. You can find more utilities like this in the web developer tools collection.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market