I am trying to remove .php extension for only pages under a subcategory folder of the website.
currently: example.com/blog/my-first-blog.php
what i want: example.com/blog/my-first-blog/
I have tried the following rule in .htaccess (placed in root) but it still shows .php
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/blog/$1.php -f RewriteRule ^(.+?)/?$ /blog/$1.php [L]
Advertisement
Answer
I figured it out
I just had to create .htaccess file under the “/guide/” directory. with the following rule note RewriteBase /guide/
for making sure it only removes .php under “/blog/” folder
RewriteEngine On RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [NC,L]