.htaccess 1.3 KB

12345678910111213141516171819202122232425262728
  1. Options -Indexes
  2. #DirectoryIndex index.php
  3. RewriteEngine On
  4. RewriteBase /
  5. # ── Allow .well-known for SSL/ACME challenges ──────────────────────────────
  6. RewriteRule ^\.well-known/ - [L]
  7. # ── Block all other dotfiles ───────────────────────────────────────────────
  8. RewriteRule (?:^|/)\. - [F,L]
  9. # ── www → non-www (301) ────────────────────────────────────────────────────
  10. RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  11. RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
  12. # ── Strip .php from the address bar (GET/HEAD only — POST submissions kept) ─
  13. # e.g. /login/login.php → /login/login
  14. RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
  15. RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?]
  16. RewriteRule ^ /%2 [R=301,L,QSA]
  17. # ── Serve extensionless URLs by mapping to the matching .php file ──────────
  18. # e.g. /login/login → /login/login.php (internal, URL stays clean)
  19. RewriteCond %{REQUEST_FILENAME} !-d
  20. RewriteCond %{REQUEST_FILENAME} !-f
  21. RewriteCond %{REQUEST_FILENAME}\.php -f
  22. RewriteRule ^(.+?)/?$ $1.php [L]