Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Simple Rewrite Rule issue

I have a bit of hard time trying to understand what is wrong with the 3rd line of this rewrite rule :

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L]
RewriteRule ^fr/lecon-de-kite\.html$ kite-lessons.php?lang=fr [L]
RewriteRule ^fr$ index.php?lang=fr [L]
RewriteRule ^it$ index.php?lang=it [L]

when I try to reach http://localhost/kitemeup/fr/lecon-de-kite.html I get an Not Found error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Have it like this in your site root .htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^fr/lecon-de-kite\.html$ kite-lessons.php?lang=fr [L]
RewriteRule ^(it|fr)/?$ index.php?lang=$1 [L,QSA]

RewriteRule ^(.+)\.html$ $1.php [L,NC]

Just understand that ordering of rules is important as mod_rewrite processes them from top to bottom. Your html -> php rule was taking precedence and converting all .html URIs to .php making your 2nd rule ineffective.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading