DevOps Generators

htaccess Generator

All tools

Type https, www or spa and get the mod_rewrite rules for that job.

How it works

Four simple steps

1

Type a mode

Enter https, www or spa in the input box.

2

Generate the rules

Press Run to get the matching rewrite block.

3

Combine if needed

Put redirects before SPA rules, with one RewriteEngine On.

4

Upload .htaccess

Place the file in your web root and test a few URLs.

htaccess Generator

About htaccess Generator

Your site on shared Apache hosting still loads over plain HTTP, or a React app returns 404 when someone refreshes on /dashboard. Both are fixed with a few lines of mod_rewrite in .htaccess, and the syntax is easy to get slightly wrong.

The input box takes one of three mode words, and Run produces the rules. https adds a 301 redirect from any HTTP request to the same host and path over HTTPS. www sends hosts that do not start with www. to the www version, also over HTTPS, in a single hop. spa serves real files and directories normally and routes every other path to /index.html, which is what client-side routers need. Any other word falls back to the https rules, so check the spelling.

Each mode outputs a complete block starting with RewriteEngine On. To combine modes, for example HTTPS plus SPA routing, put the redirect rules first and the SPA rules after them, with only one RewriteEngine line. Try a temporary 302 before committing to 301, because browsers cache permanent redirects. If the https rule loops behind a load balancer or CDN, Apache is seeing plain HTTP from the proxy, and the condition needs to check X-Forwarded-Proto instead.

The rules are generated in the browser. The HTTP status code list explains 301 versus 302, and if you run nginx rather than Apache, try the nginx server block generator.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

Not with these modes. The www option only goes from the bare domain to www. Reverse the condition and target by hand, matching hosts that start with www. and redirecting to the host without it.

Apache only reads .htaccess where AllowOverride permits it, and mod_rewrite must be enabled. On nginx and many managed platforms the file is ignored entirely.

Every path that is not an existing file or folder goes to index.html, including /api URLs served from the same host. Add a rule before it that skips your API prefix.

View more FAQs

Related tools

View all

Kubernetes Manifest Studio

Generate Deployment, Service, and Ingress YAML with a drift checklist.

Open

K8s Inspector

Summarize Kubernetes YAML kinds, names, and labels.

Open

K8s Resource Diff

Diff two Kubernetes manifests locally.

Open

K8s Manifest Splitter

Split multi-document YAML into one file per resource.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools