Apache .htaccess & Nginx 301 Redirect Rule Generator
Generate 301 redirect rules for HTTPS enforcement, www vs non-www, single pages, and domain migrations for Apache and Nginx.
Quick Answer
This tool generates 301 redirect rules for common jobs like forcing HTTPS, choosing www or non-www, and moving pages or whole domains, in both Apache .htaccess and Nginx syntax. Pick your server and scenario, enter the old and new addresses, and copy the generated code into your server configuration. Free, with everything generated in your browser.
- Pick a server (Apache or Nginx) and a common job (forcing HTTPS, www or non-www, moving pages)
- Copy the generated code for your server
- Paste it into your server configuration
Redirect Configuration
Generated Server Rules
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
How to Use Apache .htaccess & Nginx 301 Redirect Rule Generator
Follow these 3 simple steps to process your files securely in seconds.
Choose Server Type
Select Apache (.htaccess) or Nginx (nginx.conf).
Select Redirect Rule
Pick Force HTTPS, www redirection, or single page 301.
Copy Configuration
Copy generated syntax directly into your server configuration.
Why Choose Toolenix Client-Side Tools?
Engineered for US & UK professionals who value maximum data privacy, speed, and zero cloud footprints.
Apache & Nginx Support
Generates syntax for both popular web server engines.
HTTPS Force Rules
Standardizes SSL encryption redirects for SEO.
One-Click Copy
Instant copy-pasteable configuration code.
In-Depth Guide to Apache .htaccess & Nginx 301 Redirect Rule Generator
A 301 redirect tells browsers and search engines that a page has moved permanently, and passes most of its ranking power to the new address. Getting the rule wrong means visitors land on a 404 and search engines keep indexing a dead page. This tool generates the 301 rule for the common jobs — forcing HTTPS, choosing www or non-www, moving a single page, or migrating a whole domain — in both Apache .htaccess syntax and Nginx configuration, from the same inputs.
A generator, not a converter
This tool builds redirect rules from the job you pick and the old and new addresses you type in. It does not parse an existing .htaccess file and translate arbitrary RewriteRule and RewriteCond directives into Nginx syntax — that is a different, much harder job, and pasted .htaccess rules cannot be converted here. Pick the server (Apache or Nginx), pick the scenario, enter the addresses, and copy the generated snippet for that server.
Where the generated code goes
- Apache: paste the generated rules into the .htaccess file in your site's root public directory (usually public_html). Rules are read top to bottom, so specific redirects go above general ones.
- Nginx: there is no .htaccess. Place the
return 301orrewritedirective inside theserverblock for the site in your nginx.conf or site config file, then test withnginx -tand reload — a syntax error in Nginx takes the whole site down, so always test before reloading.
Getting redirects right
Use 301 (permanent) only when the move really is permanent — a 302 (temporary) tells search engines to keep the old URL indexed. Redirect to the closest matching page, not always to the homepage: a mass redirect to home looks like a soft 404 to Google. And test every rule after deploying it — a redirect loop (A points to B, B points to A) is worse than no redirect at all, and it is the most common mistake in a migration.
Frequently Asked Questions
Everything you need to know about using this free online tool.