regex - Removing .php extention and adding a / at the end -


This question is already an answer here

  • 12 replies

Expanded .php with the following code removed: (. *)

  RewriteCond% {REQUEST_FILENAME} on RewriteEngine -dRewriteCond% {REQUEST_FILENAME} \ HTML -f RewriteRule ^ $ $ 1.php  

This works I can use my site like this: www.example.com/page I have now received the following code

  RewriteCon% at RewriteEngine { REQUEST_FILENAME}! -d RewriteCond% {REQUEST_FILENAME} \. HTML-f RewriteRule ^ ([^ /] +) / $ $ 1.php # RewriteCond% {REQUEST_FILENAME} binds to add a slash! -f RewriteCond% {REQUEST_FILENAME}! -d RecoveryCand% {REQUEST_URI}! (\. [A-zA-Z0-9] {1,5} | /) $ ReWright rule (. *) $ / $ 1 / [R = 301, L]  

It also works, well closed. I was testing it in subfolders and now comes the problem:

When I go to www.example.com/sub/page it www Goes to .example.com / page / and there it says that the folder page was not found!

Is anyone's solution?

itemprop = "text">

Your rule is like this:

  RewriteCond% {REQUEST_FILENAME} RewriteCond at RewriteEngine% {REQUEST_URI}! / $ RewriteRule% {REQUEST_URI} / [L, R = 301] RewriteCond% {REQUEST_FILENAME}! -d RewriteCond% {REQUEST_FILENAME} \. -f RewriteRule ^ ([^ /] +) / $ $ 1.php [L]  

Comments