.htaccess redirect generator
Generate Apache .htaccess redirect rules, force HTTPS, set www preference and manage trailing slashes. Copy-ready mod_rewrite code.
- Free, no sign-up
- No data stored
- Reviewed 2026-01-15
Your details
Results
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
</IfModule>
Redirect note
About the .htaccess Redirect Generator
Generate ready-to-use .htaccess redirect rules for Apache servers. Add individual URL redirects (301/302), force HTTPS, set www/non-www preference and control trailing slashes. Each rule is annotated with comments.
How to use the .htaccess Redirect Generator
- Add redirect pairs (old URL → new URL).
- Select redirect type (301 permanent or 302 temporary).
- Enable force HTTPS and www options.
- Choose trailing slash policy.
- Copy the generated .htaccess rules.
Frequently asked questions
What is the difference between 301 and 302?
301 is permanent — search engines transfer link equity to the new URL. 302 is temporary — the original URL retains its SEO value.
Do I need mod_rewrite?
Yes. These rules require Apache with mod_rewrite enabled. Most shared hosting has it enabled by default.
Can I use this for nginx?
No. nginx uses a different configuration syntax. These rules are Apache-specific (.htaccess / httpd.conf).