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.

1

2 Answers 2

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/

Sign up to request clarification or add additional context in comments.

5 Comments

Infact i want server to accept the / slash at the end.
So what is your input and expected output URL?
input www.example.com/family output www.example.com/family/
and also if there is internal directory of the same page named then it becomes a problem, page and the folder doesn't load up.
no , it didn't , it says : Object not found! and it changes the root url
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.

Comments