2025-07-21 13:15:35 +04:00
|
|
|
RewriteEngine On
|
|
|
|
|
|
|
|
|
|
# ======================
|
|
|
|
|
# SÉCURITÉ
|
|
|
|
|
# ======================
|
|
|
|
|
|
|
|
|
|
# Bloquer l'accès aux fichiers de configuration
|
|
|
|
|
<Files ~ "\.(php|inc|conf|config|local)$">
|
|
|
|
|
Require all denied
|
|
|
|
|
</Files>
|
|
|
|
|
|
|
|
|
|
# Protéger les répertoires sensibles
|
2025-07-21 13:24:12 +04:00
|
|
|
RewriteRule ^(includes|cache|docs|conf)/ - [F,L]
|
2025-07-21 13:15:35 +04:00
|
|
|
|
|
|
|
|
# Bloquer les fichiers samples et backups
|
|
|
|
|
<FilesMatch "\.(sample|bak|backup|log|tmp)$">
|
|
|
|
|
Require all denied
|
|
|
|
|
</FilesMatch>
|
|
|
|
|
|
|
|
|
|
# Empêcher l'exploration des répertoires
|
|
|
|
|
Options -Indexes
|
|
|
|
|
|
|
|
|
|
# Bloquer l'accès aux fichiers cachés
|
|
|
|
|
<FilesMatch "^\.">
|
|
|
|
|
Require all denied
|
|
|
|
|
</FilesMatch>
|
|
|
|
|
|
|
|
|
|
# ======================
|
|
|
|
|
# RÉÉCRITURE D'URL
|
|
|
|
|
# ======================
|
|
|
|
|
|
|
|
|
|
# Masquer l'extension .php
|
|
|
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|
|
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
|
|
|
RewriteRule ^([^\.]+)$ $1.php [NC,L]
|
|
|
|
|
|
|
|
|
|
# Rediriger les URLs avec .php vers les URLs sans extension
|
|
|
|
|
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
|
|
|
|
|
RewriteRule ^ /%1 [NC,L,R=301]
|
|
|
|
|
|
|
|
|
|
# Pour accéder à page.php via /page
|
|
|
|
|
RewriteCond %{REQUEST_FILENAME}.php -f
|
|
|
|
|
RewriteRule ^([^/]+)$ $1.php [L]
|
|
|
|
|
|
|
|
|
|
# ======================
|
|
|
|
|
# HTTPS
|
|
|
|
|
# ======================
|
|
|
|
|
|
|
|
|
|
# Force HTTPS
|
|
|
|
|
RewriteCond %{HTTP:X-Forwarded-Proto} !https
|
|
|
|
|
RewriteCond %{HTTPS} !on
|
|
|
|
|
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|