'htaccess for multiple pages doesn't works

Start by explaining what I'm trying to do: I've got different pages on my website. Some pages have the same templates so I create one page with parameters to adapt my page: Parameters are called pageview and lang the URL looks like this:

http://mywebsite/home/en <- http://mywebsite/index.php?pageview=home&lang=en

http://mywebsite/page2/fr <- http://mywebsite/index.php?pageview=page2&lang=fr

for example. To dot that, I use the famous .htaccess file and it module rewrite_module for Apache.

I've got also a contact page with a different template. It URL looks like this and here there is only one parameter:

http://mywebsite/contact/fr <- http://mywebsite/contact.php?lang=fr

http://mywebsite/contact/en <- http://mywebsite/contact.php?lang=en

Here is my .htaccess code:

RewriteEngine On

RewriteRule ^contact/([a-zA-Z0-9]+)/?$ contact.php?lang=$1

RewriteRule ^([a-zA-Z0-9]+)$ index.php?pageview=$1 [QSA]
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?$ index.php?pageview=$1&lang=$2 [QSA]

The problem is that .htaccess file work for the index.php but not for contact.php

I can fully access to contact.php but the parameter is not detected

Thanks for your help 😀😀 !

EDIT

If I remove index parts to stay only the contact rewriteRule's the problem stay there.

contact.php and index.php are in the root folder



Solution 1:[1]

RewriteRule ^contact/([a-zA-Z0-9]+)/?$ contact.php?lang=$1

It looks like you may have a conflict with MultiViews. If MultiViews is enabled then mod_negotiation will rewrite a request for /contact/fr to /contact.php (without any parameters) before mod_rewrite is able to process the request.

Try disabling MultiViews at the top of your .htaccess file:

Options -MultiViews

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MrWhite