Skip to content
WebCraft
  • 100% client-side isolated
  • 0ms latency

.htaccess and nginx.conf generator

Toggle the rules you actually need and get equivalent Apache and Nginx syntax - with a warning wherever the two servers mean something different.

  • Apache and Nginx output
  • Syntax highlighted
  • Portability warnings
  • Nothing is uploaded

One set of switches, two server dialects

Every rule has an implementation for both servers, so switching the target never loses a setting, and the warnings panel tells you what still depends on your host.

  • 100% client-side isolated
  • 0ms latency
  • 9 rules enabled

Target server

Both files are generated from the same switches.

Redirects and errors

Where the visitor is sent, and what they see on a 404.

Headers, CORS and caching

What the response tells browsers and proxies.

Before you deploy

The parts that depend on your host.

Target
Apache
Rules
9
File
.htaccess
Lines
90
  • Note.htaccess is parsed on every request, so keep it free of rules your host already enforces.
  • CheckRedirecting to HTTPS requires a valid certificate first, or visitors get a browser warning loop.
  • CheckThe dotfile rule spares /.well-known/ so ACME certificate renewal keeps working.
  • CheckAccess-Control-Allow-Origin * cannot be combined with cookies; list explicit origins when you send credentials.

.htaccess

Upload to the document root; Apache parses it on every request.

# .htaccess - Apache 2.4+# Generated with WebCraft - https://webcraft.app/htaccess-generator # --- Canonical host redirects -------------------------------------------<IfModule mod_rewrite.c>  RewriteEngine On   # www and plain HTTP both collapse into https://example.com  RewriteCond %{HTTPS} off [OR]  RewriteCond %{HTTP_HOST} ^www\. [NC]  RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301]</IfModule> # --- Error documents -----------------------------------------------------ErrorDocument 404 /404.html # --- Compression ---------------------------------------------------------<IfModule mod_deflate.c>  AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml  AddOutputFilterByType DEFLATE application/javascript application/json  AddOutputFilterByType DEFLATE application/xml image/svg+xml</IfModule> # --- Caching -------------------------------------------------------------<IfModule mod_expires.c>  ExpiresActive On  ExpiresByType text/html "access plus 0 seconds"   # Images  ExpiresByType jpg "access plus 31536000 seconds"  ExpiresByType jpeg "access plus 31536000 seconds"  ExpiresByType png "access plus 31536000 seconds"  ExpiresByType gif "access plus 31536000 seconds"  ExpiresByType webp "access plus 31536000 seconds"  ExpiresByType avif "access plus 31536000 seconds"  ExpiresByType svg "access plus 31536000 seconds"  ExpiresByType ico "access plus 31536000 seconds"   # Fonts  ExpiresByType woff "access plus 31536000 seconds"  ExpiresByType woff2 "access plus 31536000 seconds"  ExpiresByType ttf "access plus 31536000 seconds"  ExpiresByType otf "access plus 31536000 seconds"  ExpiresByType eot "access plus 31536000 seconds"   # Styles and scripts  ExpiresByType css "access plus 31536000 seconds"  ExpiresByType js "access plus 31536000 seconds"  ExpiresByType mjs "access plus 31536000 seconds"   # Documents  ExpiresByType xml "access plus 31536000 seconds"  ExpiresByType json "access plus 31536000 seconds"  ExpiresByType pdf "access plus 31536000 seconds"   # Media  ExpiresByType mp4 "access plus 31536000 seconds"  ExpiresByType webm "access plus 31536000 seconds"  ExpiresByType mp3 "access plus 31536000 seconds"  ExpiresByType ogg "access plus 31536000 seconds" </IfModule> # --- Response headers ----------------------------------------------------<IfModule mod_headers.c>  Header always set X-Content-Type-Options "nosniff"  Header always set X-Frame-Options "SAMEORIGIN"  Header always set Referrer-Policy "strict-origin-when-cross-origin"  Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"  Header always set Cross-Origin-Opener-Policy "same-origin"  Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"   Header always set Access-Control-Allow-Origin "*"  Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS"  Header always set Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"  Header always set Access-Control-Max-Age "86400"</IfModule> # --- Block sensitive dotfiles --------------------------------------------<FilesMatch "^\.(?!well-known)">  Require all denied</FilesMatch> # Preflight requests answer 204 before the application sees them.<IfModule mod_rewrite.c>  RewriteEngine On  RewriteCond %{REQUEST_METHOD} OPTIONS  RewriteRule ^(.*)$ $1 [R=204,L]</IfModule>
directory-level configCopy with CtrlC or download the file directly.

How it works

SEO and server tooling that runs in your tab

No uploads, no sign-ups and nothing to wait for: the tags, crawl rules and server files are composed inside this page, so the result appears while you type.

  1. 1. Describe your site once

    Title, URL, image and the rules you need. The form holds everything in page state, so the same fields drive the search preview, the social cards and the generated file.

  2. 2. Flip the switches you actually need

    Open Graph, Twitter cards, HTTPS or WWW redirects, CORS, caching, security headers, crawler rules. Every option is a visible control, never a hidden default.

  3. 3. Watch the output update live

    The Google result, the Twitter and Facebook cards and the syntax-highlighted tag, robots or server file all re-render as you type — there is no submit step.

  4. 4. Check it before you ship it

    Length warnings, image URL problems, invalid crawl rules and the places where Apache and Nginx differ are listed next to the result instead of being silently dropped.

Privacy by architecture

Nothing is uploaded — and you can verify it

Privacy claims are cheap, so this one is falsifiable: the app has no upload code path at all.

  • No upload endpoint exists

    None of these tools has a POST route, a storage bucket or a proxy. Open DevTools, watch the Network tab and generate a config: the only requests are the page assets.

  • Your input stays in memory

    Titles, crawl rules and directives live in React state inside the tab and are never persisted. Close the tab and they are gone, because nothing was ever written anywhere.

  • Deterministic output, byte for byte

    The serialisers are hand-written and never consult the locale or the clock, so the same form produces exactly the same file on every run, in every browser.

Free forever, no account required — the tools are static pages that run entirely on the client.

Server config FAQ

Apache versus Nginx, redirects, security headers, CORS and caching.

What is the difference between .htaccess and nginx.conf?

.htaccess is an Apache file that lives in the document root and is re-read on every request, so it works on shared hosting where you cannot edit the main configuration. nginx.conf is a server block you place in /etc/nginx and reload, and it is faster because it is compiled into the server configuration rather than parsed per request.

How do I redirect HTTP to HTTPS?

In Apache, an unconditional rewrite inside an IfModule mod_rewrite block with RewriteCond %{HTTPS} off and a 301 rule. In Nginx, a separate server block listening on port 80 that returns a 301 to the https URL. The generator emits a canonical redirect that also fixes www in the same hop, so visitors never see a redirect chain.

Should I use www or non-www?

Either works for SEO as long as you pick one and redirect the other to it permanently. Non-www is shorter and often preferred for new sites; www keeps cookies scoped to the subdomain and is common on larger properties. The important part is that one canonical host answers and the other 301s to it.

What do the security headers actually prevent?

X-Content-Type-Options: nosniff stops the browser guessing a content type, X-Frame-Options stops your pages being framed for clickjacking, Referrer-Policy limits what leaks to third parties, and Permissions-Policy turns geolocation, microphone and camera off by default. Strict-Transport-Security makes future visits HTTPS-only after the first one.

Should I set Access-Control-Allow-Origin to a wildcard?

Only for public, credential-free resources. The wildcard cannot be combined with cookies or Authorization headers, and the browser rejects the response if you try. For an authenticated API list the exact origins, which the generator supports through the origins field or a map block in Nginx.

How long should assets be cached?

A reasonable default is one year for fingerprinted assets such as app.4f3c2a.js, one month for documents that change occasionally, and no caching at all for HTML so edits appear immediately. The generated blocks do exactly that, and the cache lifetime is a single field you can override.

Why is the dotfile rule written to skip /.well-known/?

Because /.well-known/ is where ACME certificate validation files live. Blocking every dotfile without that exception breaks automated certificate renewal, so the generated rule denies dotfiles except that directory.

Can I deploy the generated file without changing anything?

Review two environment-specific items first: an HTTPS redirect requires a valid certificate or visitors get a warning loop, and the Nginx block has commented certificate paths you need to fill in. Everything else is a syntactically valid, conservative default you can adapt in place.

  • Meta & Open Graph

    Fill a short form and get the complete <head> block: title and description limits, canonical, robots, Open Graph for Facebook and LinkedIn, Twitter cards, plus a live Google SERP, Twitter and Facebook preview and an image URL validator.

    Open tool
  • Robots.txt & sitemap

    Compose User-agent groups with Allow and Disallow rules, crawl-delay, block AI training crawlers, then add the Sitemap directives. The syntax is validated line by line and the file downloads as robots.txt.

    Open tool
  • XML sitemap

    Soon

    Paste a list of URLs and build a valid sitemap.xml with lastmod, changefreq, priority and image entries. In development on the same client-side pipeline.

    In development