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]
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
* Page erreur 404
|
* Page erreur 404
|
||||||
*/
|
*/
|
||||||
public function error_404(){
|
public function error_404(){
|
||||||
|
http_response_code(404);
|
||||||
$this->_display("error_404");
|
$this->_display("error_404");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18,6 +19,7 @@
|
||||||
* Page erreur 403
|
* Page erreur 403
|
||||||
*/
|
*/
|
||||||
public function error_403(){
|
public function error_403(){
|
||||||
|
http_response_code(403);
|
||||||
$this->_display("error_403");
|
$this->_display("error_403");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue