vendredi 21 février 2020

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




Aucun commentaire:

Enregistrer un commentaire