.htaccess & Nginx Redirect Rule Generator
Generate clean, battle-tested Apache .htaccess and Nginx rewrite rules for HTTPS forcing, 301 canonical redirects, Gzip compression, and security headers.
Select your web server environment syntax
Generated .htaccess File
0 active optimization directive(s) generated
Why Proper Server Redirects Matter for SEO
Consolidate link equity and eliminate duplicate content with 301 redirects.
301 Permanent HTTPS Redirect
Redirecting all HTTP traffic to HTTPS via a permanent 301 status code transfers 100% of link PageRank and secures user browsing sessions.
Canonical Domain (WWW vs Non-WWW)
Without canonical rewrite rules, search bots treat www.site.com and site.com as two separate duplicate websites.
Protect Sensitive Configs
Blocking public HTTP access to .env database credentials and .git version control directories prevents severe security leaks.
Frequently Asked Questions
Where is the .htaccess file located?
The .htaccess file is located in the root directory of your website (usually public_html or www) on Apache and LiteSpeed web servers.
What is the difference between a 301 and 302 redirect?
A 301 redirect is permanent and passes all ranking signals to the new URL. A 302 redirect is temporary and tells Google to keep indexing the original URL.