Z
Z
zhdoon2019-05-22 14:44:12
Apache HTTP Server
zhdoon, 2019-05-22 14:44:12

How to set redirect from upper case to lower case only for pseudo directories?

I use the solution (the very first option)

https://ru.stackoverflow.com/questions/425398/%D0%A0%D0%B5%D0%B4%D0%B8%D1%80%D0%B5%D0%BA%D1%82-url-%D0%BD%D0%B0-%D0%BD%D0%B8%D0%B6%D0%BD%D0%B8%D0%B9-%D1%80%D0%B5%D0%B3%D0%B8%D1%81%D1%82%D1%80

My .htaccess:
Options -Indexes 
ErrorDocument 404 /404.php

<IfModule mod_php5.c>
  php_flag allow_call_time_pass_reference 1
  php_flag session.use_trans_sid off

  #php_value display_errors 1

  #php_value mbstring.internal_encoding UTF-8
</IfModule>

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

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

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
  RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
  RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType image/jpeg "access plus 3 day"
  ExpiresByType image/gif "access plus 3 day"
</IfModule>

The solution works, but redirects all URLs.
Question: how to make it so that if a directory (file) of the form /CapsLoc/, CapsLoc.jpg, CapsLoc.css, CapsLoc.php, etc. physically exists, the redirect rule was not applied. But if this directory / file is not physically on the disk, then the rule with 301 redirects from upper to lower case was applied.

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