1

I was to remove .php extension by using

RewriteEngine On
RewriteRule ^([^\.]+)$ $1.php [NC,L]

but this introduced a problem which is i can't access to folder directories and their internal files and server is not even accepting trailing slash at the end.

so lets i visit this page

www.example.com/family

url will load fine

if i visit this page with / at the end

www.example.com/family/

note i have trailing slash / at the end, it won't work

now if i have a directory or folder name family

www.example/family

which is directory instead of my page then page will not work nor the directory or folder will be accessible.

2 Answers2

0

Add a Rewrite Rule to Redirect to a URL with a slash:

RewriteRule (.*)$ /$1 [L,R=301]

Input URL: http://www.example.com/family

Output URL: http://www.example.com/family/

Joseph D.
  • 11,804
  • 3
  • 34
  • 67
0

It seems like i was able to do it by using this code:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

i am pasting here, if someone else searching for the same issue.