Skip to content

HTACCESS Redirect Generator

Generate .htaccess rules for 301 redirects, www and HTTPS redirects and more.

.htaccess code


        

Paste this at the top of the .htaccess file in your site's root folder (Apache or LiteSpeed with mod_rewrite). Test in a private window: browsers cache 301 redirects.

Processing and privacy

Processing varies by tool. Check the instructions for local processing, server requests, external services and any file or request limits before entering sensitive information.

Read the privacy policy

Share this tool

Found it useful? Send it to a friend or teammate.

Rate this tool

0.0

0 ratings

  • 5 stars 0
  • 4 stars 0
  • 3 stars 0
  • 2 stars 0
  • 1 star 0

Click a star to rate this tool

Clear instructions

Find steps, examples and limitations below.

Use online

Open the tool in a supported web browser.

Free to use

No sign-up required. Tool-specific limits may apply.

How to use the HTACCESS Redirect Generator

Generate .htaccess rules for 301 redirects, www and HTTPS redirects and more.

  1. 1 Choose the redirect type and status code (301 for permanent moves).
  2. 2 Fill in the paths or domains the rule needs.
  3. 3 Copy the code to the top of the .htaccess file in your site’s root folder and test it in a private window.

Example and practical tips

To move to HTTPS and www in one hop, choose “HTTP to HTTPS and www”. The rule sends http://example.com/page straight to https://www.example.com/page.

Frequently asked questions

Does this work on Nginx?

No. .htaccess files are read by Apache and LiteSpeed. Nginx uses return or rewrite directives in its server configuration.

Why test in a private window?

Browsers cache 301 redirects, so an old rule can keep working in your normal window even after you change it.

  • How to Use HTACCESS Redirect Generator

    Generate .htaccess redirect rules for Apache: single page and folder 301s, domain moves, HTTP to HTTPS, www or non-www, trailing slashes and extensions.

Browse all guides

Report an issue

Something broken or not quite right? Tell us and we will look into it.

Accessibility Menu

Personalize your experience. Open with Ctrl+U (Option+U on Mac). Preferences stay in this browser when storage is available.

Move / Hide Widget

Restore at any time with Ctrl+U (Option+U on Mac).

Accessibility statement and help