e.g. /old /new
# Generated by Toolora
<IfModule mod_rewrite.c>
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
# Strip trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [L,R=301]
# Custom redirects
Redirect 301 /old-page /new-page
Redirect 301 /foo /bar
</IfModule>
# Enable Gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json image/svg+xml
</IfModule>
# Browser cache
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>Why .htaccess Generator
- Visual builder for Apache .htaccess.
- Force HTTPS, manage www, strip trailing slashes, custom redirects.
- Plus gzip and browser-cache directives.
Common questions
Is .htaccess Generator free to use?
Yes. .htaccess Generator is completely free. There is no sign up, no trial, and no usage cap.
Do I need an account to use .htaccess Generator?
No. You can start using .htaccess Generator straight away. We do not ask for an email address or a login.
Is my data uploaded to a server when I use .htaccess Generator?
No. .htaccess Generator runs entirely inside your browser, so the URL or details you enter never leaves your device and nothing is sent to us.
Do you store the URL or details I use with .htaccess Generator?
No. Because everything happens locally in your browser, there is nothing for us to store. Close the tab and it is gone.
Will using .htaccess Generator change my website?
No. .htaccess Generator only reads and analyzes. It never edits or publishes anything on your site.
Is the data from .htaccess Generator fetched live?
Yes. .htaccess Generator works from the current version of the page or resource you point it at.
How do I use .htaccess Generator?
Enter or paste your URL or details and .htaccess Generator updates the result as you go. When it looks right, copy or download it with one click.
Does .htaccess Generator work on phones and tablets?
Yes. .htaccess Generator is responsive and works in any modern browser on mobile, tablet, and desktop.
Which browsers does .htaccess Generator support?
It works in current versions of Chrome, Firefox, Safari, and Edge. For the best experience, keep your browser up to date.
Is there a limit on how often I can use .htaccess Generator?
No. You can use .htaccess Generator as many times as you need, at no cost.
Can I use .htaccess Generator for commercial or client work?
Yes. You are free to use the output in personal, educational, and commercial projects.
Why is .htaccess Generator free?
The site is supported by advertising, which lets us keep every tool free and open to everyone.
What should I do if .htaccess Generator gives an unexpected result?
First check that your URL or details is formatted as expected. If something still looks wrong, use the feedback link on the page and we will take a look.