When to use the .htaccess Redirect Generator
Switching to HTTPS
Make sure every visitor and search engine uses the secure version of your site.
Choosing www or non-www
Send all traffic to one version so links and rankings are not split.
Changing domain name
Move a whole website to a new domain while keeping its search rankings.
Renamed or deleted pages
Send old links to the best new page instead of a 404 error.
Features and benefits
- Force HTTPS, add www or remove www
- Move a whole site to a new domain
- Any number of single-page 301 or 302 redirects
- Warns about conflicting rules and spaces in URLs
Example
Force HTTPS + /old-page/ → https://www.example.com/new-page/
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Redirect 301 /old-page/ https://www.example.com/new-page/How the .htaccess Redirect Generator works
Site-wide rules use Apache’s mod_rewrite: a RewriteCond checks the protocol or host name, and a RewriteRule redirects to the same path on the correct address with a 301 status. A domain move matches every request whose host is not the new domain and appends the original path. Single-page redirects use the simpler Redirect directive from mod_alias, with the old path taken from whatever you paste (a full URL or a path) and checked for spaces.
A real-life example
Farhan renamed his blog’s categories, and Search Console now shows 40 “not found” errors from old links. He adds each old address and its new page here, ticks “Force HTTPS”, downloads the code and pastes it above the WordPress block in .htaccess after saving a backup. A week later the errors are gone and visitors from old links reach the right pages.
Good to know
A 301 redirect tells browsers and search engines that a page has moved permanently. Visitors land on the new address, and search engines transfer the old page’s ranking signals to the new one. A 302 means the move is temporary.
The .htaccess file controls Apache web servers, used by most shared hosting and cPanel accounts. It sits in your website’s root folder (public_html). WordPress already uses it for permalinks, so add your rules above the “# BEGIN WordPress” block.
A mistake in .htaccess can take your site offline with a “500 Internal Server Error”. Always download a backup of the existing file first, and if something goes wrong, restore the backup. Nginx servers do not use .htaccess.
Tips for the best results
- Download a backup of your current .htaccess before editing.
- Redirect each old page to the most relevant new page, not always the home page.
- Test a few old links in a private window after uploading.
- Keep redirects in place for at least a year after a move.
Common mistakes to avoid
Adding both “Add www” and “Remove www”
That creates a redirect loop. The tool warns you.
Redirect chains
Old → middle → new adds delays. Point old pages straight to the final address.
Editing .htaccess on Nginx hosting
Nginx ignores the file. Ask your host for the equivalent rules.
.htaccess Redirect Generator – frequently asked questions
Where is my .htaccess file?
In your site’s root folder, usually public_html. It starts with a dot, so turn on “show hidden files” in your file manager.
Should I use 301 or 302?
301 for permanent moves (most cases); 302 only when the old page will come back.
Does this work on Nginx or IIS?
No. These rules are for Apache and LiteSpeed servers.
Do redirects slow down my site?
A single redirect adds a tiny delay. Avoid chains of several redirects in a row.
How long do 301 redirects take to work?
Immediately for visitors; search engines update their index over days or weeks.
Can I redirect a page to another domain?
Yes. Enter the full address on the other domain as the new address.