HTACCESS Redirect Generator

Generate various types of redirects for your Apache web server's .htaccess file. Create 301 permanent redirects, 302 temporary redirects, URL rewrites, and more.

Select Redirect Type
301 Redirect

Permanent redirect that passes link equity

302 Redirect

Temporary redirect for short-term changes

URL Rewrite

Change URL structure without redirecting

WWW Redirect

Force www or non-www version of your site

HTTPS Redirect

Force secure HTTPS connections

Custom Rules

Create advanced redirect patterns

301 Permanent Redirect

Use this for permanent redirects when a page has moved permanently. Search engines will update their index and transfer link equity.

Examples: /old-page.html, /old-directory/, /products/old-product
Can be a full URL or just a path. Examples: https://example.com/new-page or /new-page
If unchecked, will redirect all pages under this path
302 Temporary Redirect

Use this for temporary redirects when a page is temporarily unavailable or for testing. Search engines will keep the old URL in their index.

Examples: /old-page.html, /old-directory/, /products/old-product
Can be a full URL or just a path. Examples: https://example.com/new-page or /new-page
If unchecked, will redirect all pages under this path
URL Rewrite

Use this to change the URL structure without redirecting. The user will see the clean URL in the browser, but the server will serve a different file.

The clean URL that users will see. Examples: /product/123, /article/my-article-title
The actual file or script that will be executed. Examples: product.php?id=123, article.php?title=my-article-title
For advanced pattern matching with capture groups
WWW Redirect

Use this to force either the www or non-www version of your website to ensure consistent URLs and prevent duplicate content issues.

Enter your domain without http:// or www. Example: example.com
Also redirect HTTP to HTTPS at the same time
HTTPS Redirect

Use this to force secure HTTPS connections for your website, which is important for security and SEO.

Leave blank to apply to any domain, or specify a domain for a specific site
HTTP Strict Transport Security tells browsers to only use HTTPS
Custom Redirect Rules

Create advanced redirect patterns for specific use cases. Use regular expressions for powerful pattern matching.

Regular expression pattern. Example: ^/old-directory/(.*)$
Use $1, $2, etc. to reference captured groups. Example: /new-directory/$1
Generated HTACCESS Code
.htaccess
Copy this code and add it to your .htaccess file. Make sure mod_rewrite is enabled on your Apache server.

How to Use the HTACCESS Redirect Generator

  1. Select the type of redirect you want to create from the options above.
  2. Fill in the required fields for your chosen redirect type.
  3. Click the "Generate" button to create the HTACCESS code.
  4. Copy the generated code and add it to your .htaccess file on your web server.
  5. Test the redirect to ensure it works as expected.
Always back up your existing .htaccess file before making changes. Incorrect syntax can cause server errors.
About HTACCESS Redirects

The .htaccess file is a configuration file for Apache web servers that allows you to control various aspects of your website, including URL redirects and rewrites.

Common Redirect Types
  • 301 Permanent Redirect: Indicates that a page has permanently moved to a new location. Search engines will update their index and transfer link equity.
  • 302 Temporary Redirect: Indicates that a page has temporarily moved to a new location. Search engines will keep the old URL in their index.
  • URL Rewrite: Changes the URL structure without redirecting. The user sees the clean URL in the browser, but the server serves a different file.
Common Use Cases
  • Website Migration: Redirecting old URLs to new ones when moving to a new domain or restructuring your site.
  • Canonicalization: Ensuring that your site is accessible from only one version (www vs. non-www, HTTP vs. HTTPS).
  • Clean URLs: Creating user-friendly URLs that hide complex query parameters.
  • Maintenance: Temporarily redirecting users to a maintenance page.
Important Considerations
  • Server Requirements: HTACCESS redirects require an Apache web server with mod_rewrite enabled.
  • Performance: Excessive redirects can slow down your website. Consider consolidating redirects when possible.
  • Testing: Always test your redirects after implementation to ensure they work as expected.
  • Redirect Chains: Avoid redirect chains (multiple redirects in sequence) as they can negatively impact SEO and user experience.
If you're using a different web server like Nginx or IIS, the syntax will be different. This generator is specifically for Apache's .htaccess files.