V
V
Vlad Avtomat2018-05-04 14:18:38
Apache HTTP Server
Vlad Avtomat, 2018-05-04 14:18:38

Tolower does not work correctly, what could be the reasons?

You need to do the task of transforming URLs into lower case.
I used this code on the local, stage, everything was fine and worked out perfectly.
But there was a problem on the prod, it redirects to the main page if you write in capital letters.
For Apache:

RewriteMap  lc int:tolower        
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/html>
            Options +Indexes +FollowSymLinks +MultiViews
            AllowOverride All
            Require all granted
        </Directory>

For .htaccess
RewriteEngine On
RewriteBase / 
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]

As a result, my .htaccess looks like this:
RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
</IfModule>

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>



RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]


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

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Redirect Trailing Slashes If Not A Folder...
    # index.php to /
    RewriteCond %{THE_REQUEST} ^(.*)\.php
    RewriteRule ^(.*)\.php$ /$1 [R=301,L]

    RewriteCond %{THE_REQUEST} ^(.*)\.html
    RewriteRule ^(.*)\.html$ /$1 [R=301,L]

    RewriteCond %{THE_REQUEST} ^(.*)\.aspx
    RewriteRule ^(.*)\.aspx$ /$1 [R=301,L]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    Options +FollowSymlinks
</IfModule>

Who knows what could be the reason that he redirects to the main page when he sees some big letters, please tell me.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question