projet_php/.htaccess
2026-03-03 22:23:25 +01:00

31 lines
No EOL
979 B
ApacheConf

Options -Indexes
<FilesMatch "(composer\.json|composer\.lock|package\.json|package-lock\.json|\.git|\.env|\.gitignore|env)">
Require all denied
</FilesMatch>
# Gestion des erreurs
ErrorDocument 404 /error/error_404
ErrorDocument 403 /error/error_403
RewriteEngine On
RewriteBase /
# Bloquer l'accès direct au dossier vendor
RewriteRule ^vendor/ - [F,L]
# Autoriser l'accès aux fichiers/dossiers physiques (images, css, js)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# RACINE : accueil par défaut
RewriteRule ^$ index.php?ctrl=project&action=home [QSA,L]
# ID NUMÉRIQUE : /ctrl/action/42
RewriteRule ^([a-zA-Z]+)/([a-zA-Z_]+)/([0-9]+)/?$ index.php?ctrl=$1&action=$2&id=$3 [QSA,L]
# PSEUDO : /user/profile/johndoe
RewriteRule ^([a-zA-Z]+)/([a-zA-Z_]+)/([a-zA-Z0-9_-]+)/?$ index.php?ctrl=$1&action=$2&pseudo=$3 [QSA,L]
# RÉÉCRITURE GÉNÉRALE : /ctrl/action
RewriteRule ^([a-zA-Z]+)/([a-zA-Z_]+)/?$ index.php?ctrl=$1&action=$2 [QSA,L]