| Code | Type | Use Case |
|---|---|---|
301 |
Permanent | Page permanently moved. Passes SEO value to the new URL. |
302 |
Temporary | Page temporarily moved. SEO stays on the original URL. |
307 |
Strict Temp | Like 302, but the request method (POST/GET) is preserved. |
.htaccess Redirect Generator
What this tool does
Add individual redirect rules (old path, redirect code, new URL) or click one of the common pattern presets to insert ready-made RewriteRule blocks. All rules are combined into a single .htaccess file you can copy or download. The reference table on the right explains when to use each redirect code.
How to use
- Click a Common Pattern (e.g. Force HTTPS) to add it instantly.
- Or enter an old path and new URL, choose a redirect type, and click Add.
- Review the rules list and remove any you do not need.
- Click Copy or Download to get the .htaccess file.
Frequently Asked Questions
What is .htaccess?
The .htaccess file is a configuration file used by Apache web servers. It lets you define URL redirects, access control, custom error pages, and URL rewriting without modifying the main server config. It takes effect immediately — no server restart required.
What is the difference between 301 and 302?
A 301 (Permanent) redirect tells browsers and search engines that the page has moved forever. Search engines transfer SEO value to the new URL. A 302 (Temporary) redirect says the move is temporary — SEO stays on the original URL and browsers do not cache the destination.
When should I use a 307 redirect?
Use 307 when you need a temporary redirect that preserves the HTTP method. A 302 may change a POST to a GET when following the redirect; a 307 guarantees the client re-sends the same method. This matters for form submissions and API redirects.
Does this work on Nginx?
No. .htaccess is an Apache-specific file. For Nginx, you need to add redirect rules to your server block configuration (nginx.conf). The logic is similar — 301, 302 codes and RewriteRule patterns — but the syntax is different.
Do I need to restart the server after changing .htaccess?
No. Apache reads .htaccess on every request, so changes take effect immediately. This is one reason .htaccess is useful for shared hosting where you cannot access the main server config.