htacc'hess
This commit is contained in:
parent
7e0ba13ad5
commit
bc05f1e7bd
2 changed files with 39 additions and 0 deletions
37
.htaccess
Normal file
37
.htaccess
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
Options -Indexes
|
||||
|
||||
# 1. On définit des URLs propres pour les erreurs
|
||||
ErrorDocument 403 /error/error_403
|
||||
ErrorDocument 404 /error/error_404
|
||||
|
||||
# --- Sécurité ---
|
||||
<FilesMatch "^\.env(\..*)?$">
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
|
||||
<FilesMatch "(composer\.json|composer\.lock|package\.json|package-lock\.json|\.git)">
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# 2. Bloquer l'accès direct au dossier vendor
|
||||
RewriteRule ^vendor/ - [F,L]
|
||||
|
||||
# 3. Autoriser l'accès aux fichiers/dossiers physiques (images, css, js)
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
# 4. RACINE : accueil par défaut
|
||||
RewriteRule ^$ index.php?ctrl=project&action=home [QSA,L]
|
||||
|
||||
# 5. 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]
|
||||
|
||||
# 6. 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]
|
||||
|
||||
# 7. RÉÉCRITURE GÉNÉRALE (inclut tes erreurs) : /ctrl/action
|
||||
# C'est cette règle qui va transformer "/error/error_404"
|
||||
# en "index.php?ctrl=error&action=error_404"
|
||||
RewriteRule ^([a-zA-Z]+)/([a-zA-Z_]+)/?$ index.php?ctrl=$1&action=$2 [QSA,L]
|
||||
Loading…
Add table
Add a link
Reference in a new issue