Tengo esta regla de reescritura en mi .htaccess
RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^/.]+)/?(.*)$ /$1.php/$2 [QSA,L] RewriteRule ^api/([az]+)/([az]+) /api/$1_$2.php
¿Cómo puedo modificar esto para cambiar todo en mi URL a minúsculas?
es decir esto:
www.mysite.com/ThisURL/SHOULD/be_all_lowercse
Debiera ser
www.mysite.com/thisurl/should/be_all_lowercase
Defina un RewriteMap de tipo int
(interno) haciendo referencia a la función de tolower
, y llámelo donde quiera hacer la minúscula:
RewriteMap lc int:tolower RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^/.]+)/?(.*)$ /${lc:$1}.php/${lc:$2} [QSA,L] RewriteRule ^api/([az]+)/([az]+) /api/${lc:$1}_${lc:$2}.php}
Este artículo describe cómo hacerlo:
RewriteEngine On RewriteMap lc int:tolower RewriteCond %{REQUEST_URI} [AZ] RewriteRule (.*) ${lc:$1} [R=301,L]