RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^blog/([^/]+)/?$ blog-details.php?slug=$1 [L,QSA] # ------------------------------ # Force HTTPS and remove www # ------------------------------ RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^(.*)$ https://dholeraindustrialplot.com/$1 [L,R=301] # ------------------------------ # Remove index.php from URL # ------------------------------ RewriteCond %{THE_REQUEST} \s/index\.php[?\s] [NC] RewriteRule ^index\.php(.*)$ https://dholeraindustrialplot.com/$1 [L,R=301] # ------------------------------ # Hide .php extension (root) # ------------------------------ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^/]+)/?$ $1.php [L] # Redirect requests with .php to extensionless URL (root) RewriteCond %{THE_REQUEST} \s/([^.]+)\.php[?\s] [NC] RewriteRule ^([^/]+)\.php$ $1 [R=301,L] # ------------------------------ # Fallback to index.php for routing (root) # ------------------------------ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L]