I have an .htaccess file in the folder www/intranet/ :
RewriteEngine On
RewriteBase /intranet/
RewriteRule ^administration/profils/editer/(\d+)/?$ administration-profils-editer.php?id=$1 [L]
RewriteRule ^article/(\d+)/?$ article.php?id=$1 [L]
The url administration/profils/editer/1/ is working fine, but url article/1/ does not works. It display the page article.php, but parameter id is not working.
Beside of that, when I hit article.php?id=1, it does work.
Also, if I do something like this in htaccess RewriteRule ^test/article/(\d+)/?$ article.php?id=$1 [L]
it works, I am getting the id parameter.
I can't get it works fine :(
This appears to be problem due to Apache's content negotiation module. This module runs before mod_rewrite
module and makes Apache server match extensions of files. So if /article
is the URI then Apache will automatically rewrites to /article.php
(if that file is found in the path). Due to this when your rewrite rule runs it doesn't match regex patten ^article/(\d+)/?$
.
You will need to turn off content negotiation feature by turning off MultiViews
option.
So in short add this line on top of your .htaccess:
Options -MultiViews