Home / SEO Tools / .htaccess Redirect Generator

.htaccess Redirect Generator

Generate .htaccess rules to force HTTPS, choose www or non-www, and set up permanent 301 redirects without writing them by hand.

Back up your current .htaccess file first. On WordPress, paste these rules above the line that says # BEGIN WordPress. This works on Apache and LiteSpeed servers. If your site sits behind a CDN or proxy, HTTPS detection can differ, so test after saving. Each redirect is a permanent 301.

What these rules do

A 301 redirect tells browsers and search engines that a page has moved permanently, so visitors and link value go to the new address. Forcing HTTPS and picking one version of your domain, with or without www, also avoids duplicate versions of your site.

How to use the generator

Enter your domain, tick the options you want and list any page redirects. Copy the rules into your .htaccess file. On WordPress, place them above the line that says BEGIN WordPress.

Test carefully

A wrong rule can cause redirect loops or take your site offline. Back up your current .htaccess first, change one thing at a time and test in a private window. These rules work on Apache and LiteSpeed servers, not on Nginx.

FAQ

It works on Apache and LiteSpeed servers that allow .htaccess files. Nginx uses a different configuration.

Use 301 for permanent moves. A 302 is temporary and tells search engines to keep the old address.

More free tools

Scroll to Top