Skip to content

Instantly share code, notes, and snippets.

@labibmuhajir
Created July 12, 2024 04:01
Show Gist options
  • Save labibmuhajir/3c6d83865209d324d61db761e84fa0bc to your computer and use it in GitHub Desktop.
Save labibmuhajir/3c6d83865209d324d61db761e84fa0bc to your computer and use it in GitHub Desktop.
2 htaccess php cpanel
# htdocs/
# ├─ public/
# │ └─.htaccess //second file
# │
# ├─ src/
# └─.htaccess //first file
# first .htaccess in root host folder
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
# second .htaccess in public folder
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment