RewriteEngine On

# Remove .php extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/.]+)$ $1.php [L]

# products  route
RewriteRule ^products/([0-9]+)$ products.php?cat_id=$1 [L,QSA]
RewriteRule ^products/([0-9]+)/([0-9]+)$ products.php?cat_id=$1&sub_id=$2 [L,QSA]
RewriteRule ^product/([0-9]+)$ product.php?pro_id=$1 [L,QSA]

RewriteRule ^articles/([0-9]+)$ article.php?prj_id=$1 [L,QSA]
RewriteRule ^articles/([0-9]+)/([0-9]+)$ article.php?prj_id=$1&article_id=$2 [L,QSA]

# Optional: index.php cleanup
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^index\.php$ / [R=301,L]