Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Generate SEO-friendly Apache mod_rewrite rules to force HTTPS, redirect www to non-www (or the reverse), and normalize trailing slashes, ready to paste into your .htaccess file.
Enter the bare domain without a scheme or path. Any https:// or leading www. you paste is removed automatically.
HTTP is always upgraded to HTTPS as part of the redirect.
On Apache servers, the .htaccess file controls how requests are rewritten and redirected. This tool writes the mod_rewrite rules for the most common canonicalization tasks, forcing HTTPS, picking a single www or non-www host, and enforcing a consistent trailing-slash style, so every visitor and search-engine crawler lands on one canonical URL. Everything is generated in your browser; nothing is uploaded.
www to the root domain or the root domain to www. HTTP is always upgraded to HTTPS as part of the same redirect.X-Forwarded-Proto / X-Forwarded-SSL to avoid redirect loops behind a TLS-terminating proxy..htaccess in your site root, then paste the rules near the top.mod_rewrite is enabled, then test a few URLs in a private window.The generator focuses on getting canonical redirects right, including the edge cases that commonly cause redirect loops. These are the features that make the output production-ready.
Canonical redirects are a routine part of launches and migrations, and this tool sits alongside the other free server and config tools from TestMu AI.
It builds Apache mod_rewrite rules for your .htaccess file that enforce a single canonical version of your site, forcing HTTPS, choosing www or non-www, and normalizing trailing slashes, so users and search engines always land on one URL.
Use 301 (permanent) for canonical HTTPS/www redirects, it passes SEO ranking signals and is cached by browsers. Use 302 (temporary) only for short-lived redirects you intend to remove later.
HSTS preload requires that the first redirect upgrades the request to HTTPS on the same host before any host change. When enabled, the generator emits a separate HTTPS upgrade first, then redirects www/non-www, keeping your site eligible for the HSTS preload list.
If your site sits behind a proxy, CDN or load balancer that terminates TLS, Apache may see the request as HTTP even though the visitor used HTTPS. This option also checks the X-Forwarded-Proto and X-Forwarded-SSL headers so you don't create a redirect loop.
They control whether a trailing slash is added (Include), stripped (Remove), or left alone (Ignore), separately for real directories, for pretty/non-file URLs, and for URLs that carry a query string. Pick one consistent style to avoid duplicate-content URLs.
Paste them near the top of the .htaccess file in your site's document root, on an Apache server with mod_rewrite enabled. Always back up your existing .htaccess first and test after deploying.
These rules are for Apache, which reads .htaccess. Nginx does not use .htaccess; it needs equivalent directives in its server config. Use this generator when your site runs on Apache or LiteSpeed.
Did you find this page helpful?
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance