.htaccess Redirect Generator

Generate Apache .htaccess rules to force HTTPS, set www or non-www, add a 301 redirect, block an IP address and enable GZIP compression.

About .htaccess Redirect Generator

This generator writes common Apache .htaccess rules from a few checkboxes and fields. You can force all traffic to HTTPS, redirect visitors to either the www or non-www version of your domain, add a permanent 301 redirect from an old path to a new one, block a single IP address, and enable GZIP compression for HTML, CSS, JavaScript, JSON and XML responses.

The file is rebuilt instantly as you change options, with a comment above each block explaining what it does. Copy the result into the .htaccess file at your site root. It is meant for Apache servers with the rewrite and deflate modules enabled; other web servers use different configuration formats.

How to use it

  1. Tick Force HTTPS and GZIP compression if you need them.
  2. Choose www, non-www or no change for your domain.
  3. Enter an old and new path for a 301 redirect.
  4. Optionally enter an IP address to block, then copy the generated file.

Questions

Where do I put the generated rules?

Save them in a file named .htaccess in your website's root folder on an Apache server, or merge them into the one already there.

Can I add more than one redirect?

The form creates one redirect at a time. Generate a rule, copy it, then change the paths and copy the next line into the same file.

More Developer & Code tools

Home · All Tools · Blog