Advertisement
.htaccess & Robots.txt Generator
Generate common Apache .htaccess rules and robots.txt directives without remembering the syntax.
Advertisement
How to Use This Generator
Tick the rules you need, fill in optional values, then copy each generated file into your project root.
- Test .htaccess changes on a staging site first โ a syntax error can 500 your whole site.
- Robots.txt blocks crawling, not indexing of already-crawled pages โ use noindex for that.
Frequently Asked Questions
Is .htaccess supported on all hosts?
No โ it works on Apache and LiteSpeed. Nginx (the other major server) does not use .htaccess; it uses server-block configs.
Does robots.txt guarantee pages aren't indexed?
No. It's a polite request that search engines usually honor. For sensitive pages use authentication or noindex meta tags.
Why does my site break after adding .htaccess?
Likely a missing Apache module (like mod_rewrite). Check the error log and remove the directive that caused it.
What is hotlinking?
Other sites embedding your images directly. Blocking it returns a 403 to those requests while letting your own domain load them.
Practical Example
For domain example.com with Force HTTPS and Disallow: /admin:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
User-agent: *
Disallow: /admin
Sitemap: https://example.com/sitemap.xml
- The first snippet forces every plain-HTTP request to redirect to HTTPS with a 301 (permanent) status.
What Your Results Mean
- .htaccess rules โ Apache directives applied per-directory; a syntax error can cause a 500 error on your whole site.
- robots.txt โ crawl directives:
User-agentselects crawlers andDisallowlists paths they should skip. - Sitemap line โ a hint to search engines where your XML sitemap lives; it must be an absolute URL.
- Blocking hotlinking โ serves a 403 to other sites requesting your images directly, while your own domain still loads them.
Trusted Sources
Advertisement