EN
My tools

.htaccess Redirect Generator (301, HTTPS, www)

Generate Apache .htaccess redirects: single pages, bulk old→new lists, HTTP to HTTPS, www or non-www, domain moves, folders, trailing slashes and .html/.php removal.

.htaccess rules
Rules
1
Module
mod_rewrite

Browsers cache permanent redirects. Test with 302 first, then switch to 301 when the rules are right; check with curl -I https://your-site/old-path.

Place the rules near the top of the .htaccess file in your web root. They need mod_rewrite or mod_alias and AllowOverride for the directory; on your own server, the same lines can go in the virtual host instead.

My tools →
Advertisement

On Apache hosting, redirects usually live in the .htaccess file: moving a page, sending every visitor to HTTPS, choosing between www and the bare domain, or moving a whole site. This generator writes the rules for those jobs — and for bulk lists of old and new addresses, folder moves, trailing slashes and hiding .html or .php — with regular-expression characters escaped and query strings handled correctly.

How to use this tool

  1. Choose the kind of redirect and the status code (301 for permanent moves).
  2. Fill in the old path and new address, the bulk list, or the domains.
  3. Copy the rules near the top of the .htaccess file in your web root.
  4. Test with a browser in a private window or curl -I, then keep the old URLs redirecting for at least a year.

Formula

mod_alias: Redirect code /old new (prefix match) or RedirectMatch code ^/old$ new (exact). mod_rewrite: RewriteCond tests (HTTPS, HTTP_HOST, QUERY_STRING), then RewriteRule ^pattern$ target [R=code,L].

In .htaccess, RewriteRule patterns are matched without the leading slash. Redirect and RedirectMatch never see the query string, so old addresses with "?" get a RewriteCond on %{QUERY_STRING}; QSD (Apache 2.4) stops the old query from being appended.

Example

HTTP → HTTPS gives RewriteEngine On, RewriteCond %{HTTPS} !=on and RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]. Moving /old-page.html to https://example.com/new-page/ gives RedirectMatch 301 ^/old-page\.html$ https://example.com/new-page/ — the dot is escaped so it only matches a real dot.

Frequently asked questions

301 or 302?

Use 301 (or 308) for permanent moves — search engines transfer the old page’s signals to the new one. Use 302 or 307 for temporary changes. Browsers cache 301s, so test with 302 first.

Why does my site loop after adding the HTTPS rule?

Usually a proxy or CDN handles HTTPS and talks to Apache over HTTP, so %{HTTPS} is always off. Tick the proxy option to check X-Forwarded-Proto instead, or set the CDN to full SSL.

Does .htaccess work on nginx?

No. nginx ignores .htaccess files; use the nginx config generator and return 301 rules in the server block instead.

Sources

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). .htaccess Redirect Generator (301, HTTPS, www). https://kakao.mobile/tools/htaccess-redirect-generator/

MLA

“.htaccess Redirect Generator (301, HTTPS, www).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/htaccess-redirect-generator/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement