RewriteEngine On

# ==========================================
# KSQUARE LOGISTICS
# ==========================================

# ------------------------------------------
# Redirect index.php to homepage
# /ksquarelogistics/index.php
# -> /ksquarelogistics/
# ------------------------------------------
RewriteCond %{THE_REQUEST} \s/+ksquarelogistics/index\.php(?:[\s?]|$) [NC]
RewriteRule ^index\.php$ /ksquarelogistics/ [R=301,L]


# ------------------------------------------
# Redirect all .php URLs to clean URLs
# /ksquarelogistics/about.php
# -> /ksquarelogistics/about
# ------------------------------------------
RewriteCond %{THE_REQUEST} \s/+ksquarelogistics/(.+)\.php(?:[\s?]|$) [NC]
RewriteRule ^(.+)\.php$ /ksquarelogistics/$1 [R=301,L,NE]


# ------------------------------------------
# Clean URL -> PHP file
# /ksquarelogistics/about
# -> about.php
# ------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/ksquarelogistics/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]