Skip to main content
100% private — runs in your browser

htaccess Redirect Generator

Generate Apache .htaccess rules for HTTPS, www, trailing slash, and redirects.

Redirect rules

.htaccess output

# Generated by The Tools Today — review before deploying
RewriteEngine On

# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Redirect to non-www
RewriteCond %{HTTP_HOST} ^www\.thetoolstoday\.com$ [NC]
RewriteRule ^ https://thetoolstoday.com%{REQUEST_URI} [L,R=301]

# Custom redirects (mod_alias Redirect)
Redirect 301 /old-page /new-page

For Apache with mod_rewrite. Test on staging first; rule order matters.

How to use htaccess Redirect Generator

  1. Set domain and options

    Enter your domain and choose HTTPS, www, and trailing-slash preferences.

  2. Add custom redirects

    Optionally list old-to-new path redirects with status codes.

  3. Copy or download

    Copy the rules into .htaccess or download the file after reviewing carefully.

Frequently asked questions

Will this work on Nginx or Vercel?

No. This generates Apache .htaccess/mod_rewrite rules. Nginx and other platforms use different configuration formats.

Should I use 301 or 302 redirects?

Use 301 for permanent moves/canonicalization. Use 302 for temporary redirects when the original URL will return.

Can redirects hurt SEO?

Correct 301 redirects preserve signals, but chains, loops, or incorrect targets can harm crawling and UX. Test thoroughly.

Is my configuration uploaded?

No. Rules are generated locally in your browser.

What if I get a redirect loop?

Check for conflicting rules (e.g. forcing HTTPS while behind a proxy) or duplicate conditions. Revert to a backup and adjust conditions like HTTPS detection.

About htaccess Redirect Generator

The htaccess Redirect Generator produces common Apache .htaccess rules for enforcing HTTPS, choosing a canonical www/non-www host, handling trailing slashes, and adding custom redirects. Correct redirect rules protect SEO signals, prevent duplicate content, and ensure users reach the right URLs. Generate and review rules locally before deploying them to your server.

Canonical redirects and SEO

Search engines prefer a single canonical form for each page. Redirecting HTTP to HTTPS and consolidating www vs non-www avoids split signals and duplicate URLs. Use permanent (301) redirects for long-term canonicalization so link equity and bookmarks transfer correctly. Always test redirects to prevent loops or chains that slow crawling and degrade user experience.

Trailing slashes and custom rules

Consistent trailing slash handling can reduce duplicate paths, but rules must account for files and existing resources. This tool offers simple add/remove options and supports custom path redirects for moved pages. Complex sites may need more specific conditions; treat generated rules as a solid starting point and adapt them to your Apache configuration and application routing.

Safe deployment

Rules are generated in your browser and not uploaded. Before going live, back up your existing .htaccess, test on staging, and verify with curl or browser devtools. Misconfigured rewrite rules can block access or create redirect loops. Ensure mod_rewrite is enabled on your server and place rules in the appropriate directory context.

Use htaccess Redirect Generator on your site

This tool runs free and private in the browser. Paste it anywhere — blog posts, documentation, team wikis — and your visitors will use it without leaving your site. The embed includes a small "Made with The Tools Today" credit link.

Open the tool page →

Your privacy, your choice

We use cookies to understand how the site is used and to show relevant ads. Every tool on this site runs entirely in your browser, so the files and text you process are never uploaded. Read our privacy policy.