.htaccess Redirect Generator
Create 301 redirects for Apache servers. Generate bulk URL redirects for site migrations, domain changes, and SEO-friendly page redirection.
TL;DR: URL redirects tell browsers and search engines that a page has moved. Get them wrong during a site migration and you'll lose rankings, break bookmarks, and frustrate users. This free .htaccess redirect generator creates properly formatted 301 redirect rules for Apache servers, so you don't have to remember the syntax.
What Is a 301 Redirect and Why It Matters for SEO
A 301 redirect is an HTTP status code that tells browsers and search engines: "This page has permanently moved to a new location." When someone visits the old URL, they're automatically sent to the new one.
For SEO, 301 redirects are critical. They pass link equity (ranking power) from the old URL to the new one. Without proper redirects, you lose the backlinks you've built, your rankings drop, and Google indexes both old and new URLs as separate pages.
The .htaccess file is where Apache servers store redirect rules. One syntax error and your entire site can break. This generator creates the correct code so you can focus on your migration strategy, not debugging server configuration.
How to Use This .htaccess Redirect Generator
This tool creates bulk 301 redirect rules you can copy directly into your .htaccess file:
- Enter your old URL (the one that's changing or no longer exists).
- Enter your new URL (where visitors should be sent).
- Add more redirects as needed for bulk URL changes.
- Select redirect type (301 permanent or 302 temporary).
- Copy the generated code and paste it into your .htaccess file.
The generator handles the RewriteRule syntax automatically. Just provide the URLs and get working code.
301 vs 302 Redirect: Which Should You Use?
This is one of the most common SEO redirect questions. Here's the difference:
| Type | Meaning | SEO Impact | When to Use |
|---|---|---|---|
| 301 | Permanent redirect | Passes ~90-99% of link equity | URL changes, migrations, merging content |
| 302 | Temporary redirect | Does not pass link equity | A/B testing, temporary maintenance |
Rule of thumb: If the URL change is permanent, use 301. If you plan to bring the old URL back, use 302. When in doubt, 301 is almost always the right choice for SEO redirects.
Common .htaccess Redirect Examples
Here are the most common redirect scenarios and their .htaccess code:
Single Page Redirect
Redirect 301 /old-page/ https://example.com/new-page/
Redirect Entire Domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*)$ https://newdomain.com/$1 [R=301,L]
HTTP to HTTPS Redirect
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Non-WWW to WWW Redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule (.*)$ https://www.example.com/$1 [R=301,L]
Redirect Directory to New Location
RewriteEngine On RewriteRule ^blog/(.*)$ /articles/$1 [R=301,L]
Where Is the .htaccess File? How to Edit It
The .htaccess file is located in your website's root directory (the same folder as index.html or index.php). Here's how to find and edit it:
.htaccess File Location by Platform
| Platform | File Location | How to Access |
|---|---|---|
| WordPress | /public_html/.htaccess | FTP, cPanel File Manager, or Yoast SEO |
| cPanel Hosting | /public_html/.htaccess | File Manager → Show Hidden Files |
| Shared Hosting | /www/ or /htdocs/ | FTP client (FileZilla, Cyberduck) |
| Custom Server | /var/www/html/ | SSH terminal or SFTP |
Important: The .htaccess file is hidden by default because it starts with a dot. Enable "Show Hidden Files" in your file manager or FTP client. Always backup your .htaccess before editing. A syntax error can take your entire site offline.
Redirects in WordPress
WordPress sites have several options for managing URL redirects:
- Edit .htaccess directly — Use FTP or your hosting file manager to add redirect rules manually.
- Yoast SEO Premium — Has a built-in redirect manager that creates .htaccess rules or database redirects.
- Redirection plugin — Free plugin that manages redirects through the WordPress admin. Creates Apache or PHP redirects.
- Rank Math — Includes redirect management in the free version.
For bulk site migrations with hundreds of redirects, .htaccess is faster than plugin-based solutions. For occasional single redirects, a plugin is more convenient.
Redirect Best Practices for SEO
Follow these rules to preserve your SEO value during URL changes:
- Always use 301 for permanent changes. This tells Google to transfer ranking signals to the new URL.
- Avoid redirect chains. Page A → B → C loses link equity at each hop. Redirect directly from A → C.
- Update internal links. Don't rely on redirects for internal navigation. Change links to point to new URLs directly.
- Keep redirects for at least 1 year. Google needs time to discover and process redirects. Removing them too soon causes 404 errors.
- Redirect to relevant content. Redirecting all old pages to your homepage is a soft 404. Redirect each page to its closest equivalent.
- Monitor in Search Console. After a site migration, check for crawl errors and indexing issues.
Troubleshooting: Why Your Redirect Isn't Working
Redirects not working? Here are the most common causes:
mod_rewrite not enabled
Apache needs mod_rewrite module enabled for RewriteRule directives. Contact your host or check httpd.conf. Use simple Redirect directives as an alternative.
AllowOverride disabled
Your Apache config must have AllowOverride All for .htaccess to work. Shared hosts usually have this enabled; VPS/dedicated servers may not.
Syntax errors in .htaccess
One typo can cause a 500 Internal Server Error. Check for missing spaces, unclosed brackets, or incorrect flags. Test each rule individually.
Browser caching old redirect
Browsers cache 301 redirects aggressively. Clear your browser cache or test in incognito mode to see the current behavior.
Conflicting rules
Rule order matters. More specific rules should come before general ones. WordPress, plugins, or your theme may have their own .htaccess rules that conflict.
Frequently Asked Questions
Do redirects affect SEO rankings?
Properly implemented 301 redirects pass most ranking signals to the new URL. There may be a small, temporary drop during reindexing, but your rankings should recover. The key is using 301 (not 302) and redirecting to relevant content, not just your homepage.
How long does it take for Google to process redirects?
Google typically processes redirects within a few days to a few weeks, depending on how often it crawls your site. You can speed this up by submitting updated URLs in Google Search Console. For large site migrations, full processing can take several months.
Can I use .htaccess on Nginx servers?
No. .htaccess is Apache-specific. Nginx uses different configuration files (usually in /etc/nginx/). If you're on Nginx, you'll need to add redirect rules to your server block configuration instead. The syntax is different but the concept is the same.
Should I redirect HTTP to HTTPS?
Yes, absolutely. After installing an SSL certificate, redirect all HTTP traffic to HTTPS. This prevents duplicate content issues and ensures all visitors get the secure version. Google also uses HTTPS as a ranking signal.
How many redirects are too many?
There's no hard limit, but redirect chains (multiple hops) hurt performance and SEO. Each redirect adds latency. Keep it to one redirect per URL. For thousands of individual redirects, .htaccess performance is fine, but consider using a redirect map for very large sites.
What happens if I remove redirects too soon?
Old URLs will return 404 errors. Any bookmarks, backlinks, or search results pointing to old URLs will break. Google recommends keeping redirects in place for at least one year, ideally permanently for important pages with external backlinks.
Where in .htaccess should I place redirect rules?
Place redirect rules near the top of your .htaccess file, after RewriteEngine On but before WordPress or CMS-specific rules. Order matters: more specific rules should come before general patterns.
Generate Your Redirect Rules
URL redirects are essential for site migrations, domain changes, and maintaining SEO value when URLs change. A single syntax error can break your site. A missing redirect can lose years of link building.
Use the .htaccess redirect generator above to create properly formatted rules. Test them on a staging environment if possible, then deploy to production. Monitor Google Search Console for crawl errors after major redirect implementations.
Related Free SEO Tools
Redirects work alongside other technical SEO elements:
- Bulk HTTP Status Checker — Verify your redirects are working correctly and returning 301 status codes.
- XML Sitemap Generator — Update your sitemap after migrations to include only new URLs.
- Robots.txt Generator — Ensure search engines can crawl your redirected pages.