.htaccess Rewrite Rule & 301 Redirect Generator
Generate copy paste Apache .htaccess 301 redirects, mod_rewrite rules, and Nginx configurations entirely in your browser. 100% free web utility.
How to Use the .htaccess Rewrite Rule & 301 Redirect Generator
- 1 Select your web server architecture: Apache (.htaccess) or NGINX (nginx.conf).
- 2 Choose a rule preset: Single 301 redirect, Force HTTPS, WWW canonicalization, Trailing slash, or Bot blocker.
- 3 Configure source and target URL parameters.
- 4 Copy or download the production-ready server configuration file directly.
Methodology & Algorithmic Standards
Compiles strict Apache mod_rewrite directives (`RewriteRule`, `RewriteCond`) and NGINX return blocks (`return 301`, `rewrite ^...$ ... permanent`), preserving query strings and canonical link equity.
Frequently Asked Questions
How do I redirect an entire domain in .htaccess? ▼
Declare RewriteEngine On, match the old host with RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC], and apply RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L,NE]. This permanently transfers every path and URL parameter cleanly to your new domain.
What is the difference between 301 and 302 redirects? ▼
A 301 redirect signals a permanent move, instructing Google and search engines to transfer canonical link equity (PageRank) to the destination URL and update their index. A 302 redirect indicates a temporary move, keeping the original URL indexed for promotions or short term maintenance.
How do I fix redirect loops in Apache? ▼
Infinite ERR_TOO_MANY_REDIRECTS loops typically stem from conflicting HTTPS or WWW rules, missing [L] (Last Rule) flags, or a reverse proxy like Cloudflare forwarding HTTP to Apache. Check X-Forwarded-Proto headers using RewriteCond %{HTTP:X-Forwarded-Proto} !https and consolidate duplicate host rules.
Explore Related Developer Tools
JSON Formatter, Minifier & Syntax Linter
Fast, client side JSON beautifier, minifier, and error linter. Safely formats code with 2 space or 4 space indentation and pinpoints exact syntax error line numbers.
Base64 Text & String Encoder / Decoder
Safely encode and decode UTF8 text and Unicode characters to and from Base64 with instant copy, byte telemetry, and zero server logging.
URL Slug & Query Parameter Parser
Deconstruct any web URL into protocol, host, port, path, and an interactive editable table of query parameters with live re assembly and copy.