Htaccess changes url if directory exists

The problem I am facing is that when the url contains an existing directory, the url changes in the case of a file.

Specifically, this is what happens:

When I go to domain.com/cron/xxx

, then in my PHP script, it uri

will be:

cron/xxx

      

But if the folder exists Cron

, then it uri

will be:

cron/xxx

      

Does anyone know why this is happening?

Here is my file .htaccess

:

RewriteEngine On

#remove www.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^api
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?uri=api/$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?uri=$1 [L,QSA]

      

+3


source to share


1 answer


I'm not super knowledgeable about ModRewrite, but you can try:

RewriteMap  lc int:tolower

      



and then use it in your rule like so:

RewriteRule (.*) ${lc:$1} [R=301,L]

      

0


source







All Articles