.htaccess Redirect Generator

Free .htaccess redirect generator: create 301 and 302 redirects, force HTTPS, www or non-www, move a domain and turn dynamic URLs into clean ones.

  • 100% free
  • No sign-up
  • Runs in your browser
What it does: Sends visitors and search engines from the old page to the new one for good. The new page inherits the old page’s value.
These rules need an Apache server with mod_rewrite, which most shared hosting has. Back up .htaccess before editing: one wrong character can stop the whole site with a 500 error. On Nginx, use return 301 or rewrite in the server settings instead.
.htaccess rules
Redirect 301 /old-page.html https://example.com/new-page/

Turn a dynamic URL into a clean, SEO-friendly URL

Paste a URL with query parameters (like ?id=42) to get a clean URL and the matching Apache and Nginx rewrite rules.

Before (dynamic)

https://example.com/product.php?id=42&category=shoes

After (static, SEO-friendly)

https://example.com/product/42/shoes/

Apache .htaccess
RewriteEngine On
RewriteRule ^product/([^/]+)/([^/]+)/?$ product.php?id=$1&category=$2 [L,QSA]
Nginx
rewrite ^product/([^/]+)/([^/]+)/?$ /product.php?id=$1&category=$2 last;

Why rewrite URLs?

  • Keywords in the path are a minor ranking signal and improve click-through rates.
  • Static-looking URLs are easier to share, remember and cite.
  • Fewer parameters mean fewer duplicate-content variations for crawlers.
  • Remember to 301-redirect the old dynamic URLs and update your canonical tags.

Webmaster Tools

About the .htaccess Redirect Generator

The .htaccess Redirect Generator writes redirect rules for Apache web servers, which most shared hosting uses. Choose what you need: a 301 or 302 redirect for one page, forcing HTTPS, choosing www or non-www, moving a whole site to a new domain, adding or removing trailing slashes, hiding index.php or .html, or custom error pages.

Each option comes with a short explanation of what the rule does. Copy the result into the .htaccess file in the root folder of your site.

Below it, the URL rewriter turns a dynamic address such as product.php?id=42 into a clean, readable address, with matching Apache and Nginx rewrite rules.

How to use this tool

  1. 1Choose the redirect type.
  2. 2Fill in the old path and new address, or your domain.
  3. 3Copy the generated rules.
  4. 4Back up your .htaccess file, then paste the rules near the top.
  5. 5Test the result with the Redirect Checker.

Best-practice tips

  • Use 301 for permanent moves; it passes the old page’s value to the new one.
  • Always back up .htaccess first: one wrong character can take the whole site offline with a 500 error.
  • Avoid stacking rules that redirect into each other; that creates chains and loops.
  • On Nginx servers .htaccess does nothing. Use the Nginx rules shown by the URL rewriter, or your host’s settings.

Common redirect setups

  • Moving one page: a 301 from the old path to the new address.
  • Switching to HTTPS: the "Force HTTPS" rule, after your SSL certificate is installed.
  • Picking one main version: www → non-www or the other way round, so search engines see one site, not two.
  • Changing domain: "Old domain → new domain" keeps every path, so old links still land on the right page.

After uploading, test each important old address with the Redirect Checker to make sure there are no chains or loops.

Answers

.htaccess Redirect Generator FAQs

Choose "301 Permanent", enter the old path and new address, then copy the line into your .htaccess file.

Related tools

Continue with these related webmaster tools.