0

I have already spent many hours on this and I think I could use some help. So I have a local zend project available at http://MY_URL.lh.

I have this htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# RewriteRule ^.*$ /index.php [NC,L]
RewriteRule !\.(js|ico|gif|jpg|png|css|wfs|csv)$ index.php

And I want to rewrite this :

htttp://MY_URL.lh/en 

into this:

htttp://MY_URL.lh/?lang=en

I have tryed already to add my rule

RewriteRule /^([a-z]{2})$ /?lang=$1 [R]

before the

RewriteRule ^.*$ - [NC,L]

but then no further zend routing works except if I add the flag [C] to my rule but the desired behaviour still missing.

Also I have tried with [R=301] flag.

I would appreciate to know why is so difficult to make htaccess rewrite rules in Zend Projects.

Thank you for your answers!

1 Answers1

0

Try adding this rule before the other rules i.e. just after the RewriteEngine On

RewriteRule ^([a-z]{2})$ /?lang=$1 [R=301,L]

When you added it right before RewriteRule ^.*$ - [NC,L], this rule, which says stop processing all requests, gets executed all the time, which is why nothing works after.

Edit:

If you do not want to change the address in the URL, which is what the redirect will do, then I presume that you want to continue processing rules after this too, so that the php application will be able to pick up the lang param. In this case, leave the rule where it is but remove both flags and add the QSA flag in case there are other query string parameters present.

RewriteRule ^([a-z]{2})$ /?lang=$1 [QSA]
Ulrich Palha
  • 9,411
  • 3
  • 25
  • 31