From d481aafc70c1946b277059295111de69e458bc91 Mon Sep 17 00:00:00 2001 From: Dharma Date: Thu, 20 Feb 2025 13:49:42 +0545 Subject: [PATCH] message: htaccess created --- .htaccess | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.htaccess b/.htaccess index 2e81a07..f5ab603 100644 --- a/.htaccess +++ b/.htaccess @@ -1,6 +1,27 @@ -RewriteEngine On -RewriteBase / +# RewriteEngine On -# Remove .php extension from URLs -RewriteCond %{REQUEST_FILENAME}.php -f -RewriteRule ^(.*)$ $1.php [L,QSA] +# # Remove .php extension from URLs (e.g., /contactt -> contact.php) +# RewriteCond %{REQUEST_FILENAME} !-d +# RewriteCond %{REQUEST_FILENAME}\.php -f +# RewriteRule ^(.*)$ $1.php [L] + +# # Redirect direct access to .php files to clean URLs (optional) +# RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC] +# RewriteRule ^ /%1 [R=301,L,NE] + + +RewriteEngine On +DirectoryIndex index.php + +# 1. Redirect any index.php request to its directory URL +RewriteCond %{THE_REQUEST} \s/(.*)index\.php[\s?] [NC] +RewriteRule ^(.*)index\.php$ /%1 [R=301,L] + +# 2. Remove .php extension from URLs (e.g., /contactt -> contact.php) +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME}\.php -f +RewriteRule ^(.*)$ $1.php [L] + +# 3. Redirect direct access to .php files to clean URLs (optional) +RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC] +RewriteRule ^ /%1 [R=301,L,NE]