What is .htaccess redirect generator?
Redirects send visitors and search engines from one URL to another. A 301 redirect tells search engines that the move is permanent, so most ranking signals pass to the new address.
Rewriting rules in .htaccess are easy to get wrong. This generator gives tested snippets for the most common jobs on Apache servers, which includes most shared hosting such as Hostinger.
How to use the .htaccess redirect generator
- Choose the type of redirect you need.
- Fill in the old path and new URL if the type needs them.
- Press Generate and paste the rules into your .htaccess file, above any existing WordPress rules.
How the .htaccess redirect generator works
Single redirects use the Redirect 301 directive. HTTPS, www and slash rules use mod_rewrite with RewriteCond and RewriteRule and a 301 status. Domain moves rewrite every path to the same path on the new domain.
Worked example
Common uses of the .htaccess redirect generator
- Moving pages after a redesign.
- Forcing all traffic to HTTPS.
- Choosing one canonical version, www or non www.
- Fixing broken links by redirecting them.
- Moving a site to a new domain.
Tips and common mistakes
Back up your .htaccess file first. A single typo can cause a server error.
Avoid redirect chains. Point old URLs straight to the final destination.
Background: what to know before you rely on it
Search engines treat a 301 as a signal that the old URL has moved permanently and that the new URL should replace it in the index. A 302 is temporary, so the old URL usually stays indexed. Redirect chains slow pages down and can lose signals, so link directly to the final address. Domain moves need extra care: redirect every old URL to its exact match, update canonical tags, sitemaps and internal links, and tell Google through the Change of Address tool in Search Console. After any redirect change, test with a few URLs, check the status codes and watch the Search Console coverage reports for errors.
Private, free and fast
This tool runs entirely in your browser. What you type or choose is not uploaded to a server and is not saved after you close the page, which keeps it fast and private. It is free to use as often as you like. See more in all seo tools, or browse the full list of tools.
Frequently asked questions
Where is the .htaccess file?
In the root of your site, often inside public_html.
What is a 301 redirect?
A permanent redirect that passes most SEO value to the new URL.
Does this work on Nginx?
No. Nginx uses a different syntax.
How long should I keep redirects?
At least a year, and ideally as long as the old URL still has links.
Related tools
Sitemap XML Generator
Paste one URL per line and the generator builds a valid sitemap.xml you can upload to your site and...
SEO ToolsRobots.txt Generator
Enter the paths you want to block, add your sitemap and download a ready robots.txt for the root of your...
Developer ToolsURL Encoder and Decoder
URL encoding replaces unsafe characters with a percent sign and two hex digits so a link works...
Name and ID GeneratorsDomain Name Generator
Type one or more keywords and choose an extension. The generator mixes your words with popular prefixes...
SEO ToolsMeta Tag Generator
Enter your page title, description and URL and the generator writes the HTML meta tags, including Open...
SEO ToolsUTM Link Builder
Enter your URL with a source and medium, plus optional campaign details. The tool returns a tagged link...
Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional. Validate markup with search engine testing tools before publishing.