About .htaccess redirects
This tool builds .htaccess redirect rules for Apache and LiteSpeed servers — force HTTPS, redirect www to non-www (or back), add or remove trailing slashes, and create 301 redirects for specific URLs. Tick what you need and copy the rules. It runs in your browser.
How htaccess Redirect Generator works
How to use it
- Enter your domain.
- Tick the rules you want and add any single-page redirects.
- Copy the rules into the .htaccess file at your site root.
How it works
Apache and LiteSpeed read directives in a .htaccess file to rewrite and redirect requests. This tool assembles the correct RewriteCond/RewriteRule and Redirect 301 directives for the common cases so you don't have to remember the syntax.
Be careful
Always back up your existing .htaccess first, and don't enable conflicting rules (both www options, or both trailing-slash options) at once. Test your site after applying changes.
Common uses
- Force HTTPS site-wide
- Redirect www to non-www
- Redirect non-www to www
- Add or remove trailing slashes
- Create 301 redirects for old URLs
- Fix duplicate-URL issues
- Set a canonical host
- Generate rewrite rules quickly