Why does not work like this (gives 404)

RewriteRule ^(company)/services/$ /company/branches.php [L] 

Rename the company folder to company2. I do so.

 RewriteRule ^(company)/services/$ /company2/branches.php [L] 

And for the same link ( example.dev/company/services/ ) everything works fine. Not the first time already such a problem. Terribly annoying. What can you do about it?

Additional information: Xdebug showed that there is no request to the /company/branches.php file at all. He immediately goes to show page 404. There are rights to read. No redirects occur.

And it behaves as if the files in this folder do not exist at all ... What could it be at all?

PS Ubuntu 16.04

  • If you remove the brackets (company) , how does it behave? - Visman
  • Also .. if you do RewriteRule ^(company)/services2/$ /company/branches.php [L] And go to the link company / services2 / everything will work. And on one server, under debian, it works fine, but on the other under ubuntu, he does not want to display anything - Vitaly Zaslavsky
  • Do you have sukhosin or similar protection are not on the server? - Visman
  • No, not worth it. From the server settings removed Options + MultiViews. Earned almost everything. But now if I try to go to the link / services / Gives out forbidden. That is, he is trying to access the folder of the same name, instead of looking at mod_rewrite and giving me the desired page. What did I do again? - Vitaly Zaslavsky
  • Everything, it was enough to remove MultiViews and everything now works. - Vitaly Zaslavsky

1 answer 1

In the course of experiments at random, it was revealed that the Options +MultiViews parameter was responsible for such bad behavior. Googling showed that because of this directive, the server can produce all sorts of files and work very unpredictably if the system was not originally designed for this. So, the usual deletion of this line from the config of my server solved all my problems. Now I understand why the server bypassed mod_rewrite and gave me a 404 error.