Apache .htaccess Redirect Generator

Generate 301 and 302 redirect rules for Apache .htaccess files. Force HTTPS, WWW redirects, custom 404. Free htaccess redirect generator.

Type Old Path New URL

What is .htaccess?

.htaccess (hypertext access) is a configuration file for Apache web servers. It allows you to control server behavior on a per-directory basis without modifying the main server configuration. Common uses include URL redirects, password protection, and custom error pages.

Common Redirect Types

  • 301 Permanent: Permanent redirect, passes SEO value
  • 302 Temporary: Temporary redirect, doesn't pass SEO value
  • HTTP to HTTPS: Forces secure connections
  • WWW to non-WWW: Standardizes domain format

Why Use Redirects?

  • Maintain SEO rankings when changing URLs
  • Fix broken links and 404 errors
  • Enforce HTTPS for security
  • Consolidate duplicate content
  • Rename or restructure website URLs

Frequently Asked Questions

What is the difference between 301 and 302 redirects?
A 301 redirect is permanent and tells search engines to transfer SEO value to the new URL. A 302 redirect is temporary and doesn't transfer SEO value. Use 301 for permanent URL changes and 302 for temporary maintenance or testing.
How do I force HTTPS with htaccess?
Add this code to your .htaccess file: RewriteEngine On, RewriteCond %{HTTPS} off, RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]. This redirects all HTTP traffic to HTTPS.
How do I redirect www to non-www?
Use: RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC], RewriteRule ^(.*)$ https://%1/$1 [R=301,L]. This redirects www.example.com to example.com while preserving the path.
Where do I put the htaccess code?
Place the generated code in your .htaccess file in the root directory of your website. If the file doesn't exist, create it. Always backup your existing .htaccess before making changes.