RewriteEngine On # ------------------------------------------------- # 1. Hide index.php everywhere (root + subfolders) # ------------------------------------------------- RewriteCond %{THE_REQUEST} \s/+(.*/)?index\.php[\s?] [NC] RewriteRule ^ %1 [R=301,L] # ------------------------------------------------- # 2. Block direct .php access # ------------------------------------------------- RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC] RewriteRule ^ - [R=404,L] # ------------------------------------------------- # 3. Root product slug only # ------------------------------------------------- RewriteRule ^product/([a-zA-Z0-9-]+)/?$ product.php?slug=$1 [L,QSA] # ------------------------------------------------- # 4. Directory → index.php auto load # ------------------------------------------------- RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME}/index.php -f RewriteRule ^(.*/)?$ $1index.php [L] # ------------------------------------------------- # 5. Extensionless for all php # ------------------------------------------------- RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+?)/?$ $1.php [L] ErrorDocument 404 /404.php # php -- BEGIN cPanel-generated handler, do not edit AddHandler application/x-httpd-ea-php81 .php .php8 .phtml # php -- END cPanel-generated handler, do not edit