1

Some people want to access .php files without the extension. For example :

Accessing example.com/user.php?id=42 via example.com/user/42

My problem is : I don't want it. Even without any .htaccess file at all, when I go to mywebsite.com/foo it will render then serve mywebsite.com/foo.php.

How can I prevent this ?

My original problem is the following :

I want to rewrite mywebsite.com/user/grades/foo/bar to mywebsite.com/user/grades.php?user=foo&exam=bar

But, it won't work because Apache will render grades.php even without the extension. The rewrite won't work because the original URL exists.

palmtreesnative
  • 2,835
  • 3
  • 14
  • 22
  • Does this answer your question? [Removing the .php extension with mod\_rewrite](https://stackoverflow.com/questions/4908122/removing-the-php-extension-with-mod-rewrite) – Night King Jul 01 '20 at 15:54
  • @NightKing no, it does the contrary. This answer allows somebody to redirect foo to foo.php Me, I want to connect to /foo and not be redirected to /foo.php – palmtreesnative Jul 01 '20 at 16:20
  • dont know if thats possible, as the whole idea behind mod_rewrite was this but u can try routing all request to a front controller which then calls other php this may allow you to utilize that sort of url arrangement. – Night King Jul 01 '20 at 19:36

1 Answers1

0

Disable the MultiViews option:

Options -MultiViews
CBroe
  • 91,630
  • 14
  • 92
  • 150