Free Online .htaccess Redirect & Rewrite Rule Generator
.htaccess Redirect & Rule Generator
Generate Apache 301 redirects, HTTPS rules, caching and security headers * 100% free * No upload
About This Free Online .htaccess Generator
One stray space or broken flag in an Apache config file is enough to throw a 500 Internal Server Error across your whole site. This free online htaccess generator writes clean, tested Apache rewrite rules without making you memorize syntax. Toggle force HTTPS, pick www or non-www canonicalization, turn on Gzip compression and browser caching, and paste bulk 301 redirect rules all in one spot. You can also add security headers and block direct requests to hidden dotfiles like .env. Everything builds locally in your browser tab.
How This Generator Builds Apache Rules
Each toggle maps to standard Apache modules like mod_rewrite, mod_expires, mod_deflate, and mod_headers, wrapped in <IfModule> blocks where needed so your server doesn't crash if a module is missing. When you list old and new URLs in the redirect box, the script splits each line by comma and writes a Redirect 301 or Redirect 302 directive in order.
How to Use It
- Enter your domain name if you're using non-www/www redirects or hotlink protection.
- Check the HTTPS, caching, compression, and security options you want active.
- Add any old-to-new URL pairs in the bulk redirect box, one per line.
- Copy the output or download the
.htaccessfile, then upload it to your site's public root folder (oftenpublic_html).
Before You Upload to Your Server
- Download a backup copy of your existing
.htaccessfile first so you can roll back in ten seconds if a rule clashes with WordPress or another CMS. - Keep CMS-specific blocks (like WordPress's
# BEGIN WordPressblock) intact and paste custom redirects above them. - Test permanent 301 redirects in an incognito window because browsers cache 301 responses aggressively.
Frequently Asked Questions
Why did my site show a 500 error after editing .htaccess?
That usually happens when a required Apache module isn't enabled on your host, or when an old rule wasn't wrapped in an IfModule check. Restore your backup copy and enable one section at a time.
Should I use 301 or 302 for my redirects?
Use 301 when a page has moved for good and you want search engines to pass link equity to the new URL. Use 302 only for temporary campaigns or maintenance pages.
Does this work on Nginx servers?
No. Nginx ignores .htaccess files completely; these rules are specifically for Apache and LiteSpeed servers.
Where do I put the .htaccess file in cPanel?
Open File Manager, turn on "Show Hidden Files" in Settings, and place the file inside public_html (or the subfolder for an addon domain).
Is my domain or redirect list sent anywhere?
No. The file is assembled in JavaScript inside your browser, and nothing is saved or transmitted.
Comments
Post a Comment