V
V
VPVPVP2020-12-11 16:08:43
htaccess
VPVPVP, 2020-12-11 16:08:43

What's wrong with this htacess?

I use this htacess, but something is wrong with it. When I remove this htacess, buttons work in the admin panel, in this htacess there are redirects from www to without www, from upper to lower case, etc.
Tell me what's wrong with it?
Shows that I have mixed content in the admin panel when this htacess is present and a couple more points.

#order deny,allow
#deny from all

RewriteEngine on
RewriteBase /

############################################################################
#### Убираем повторяющиеся слеши (/) в URL                              ####
############################################################################
RewriteCond %{THE_REQUEST} //
# Проверяем, повторяется ли слеш (//) более двух раз.
RewriteRule .* /$0 [R=301,L]
# Исключаем все лишние слеши.

php_value error_reporting 1

RewriteCond %{HTTP_USER_AGENT} ^.*(Chrome/76.0.3809.100).*$ [NC]
RewriteRule .* - [F,L]

#### Убираем слеши в конце URL для статических файлов (содержит точку)  ####
############################################################################
RewriteCond %{REQUEST_URI} \..+$  
   # Если файл содержит точку.
RewriteCond %{REQUEST_FILENAME} !-d   
   # И это не директория.
RewriteCond %{REQUEST_FILENAME} -f
   # Является файлом.
RewriteCond %{REQUEST_URI} ^(.+)/$      
   # И в конце URL есть слеш.
RewriteRule ^(.+)/$ /$1 [R=301,L]     
   # Исключить слеш.
   
######regist####
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]
####

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L]

#RewriteCond %{REQUEST_URI} !^/$
#RewriteCond %{REQUEST_URI} (.*)/$
#RewriteRule . %1 [R=301,L,E=NS:1,QSA]

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

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

Redirect 301 /site/index /

RewriteCond %{REQUEST_URI} !^/generate-webp.php$ 
RewriteCond %{REQUEST_URI} !^/sitemap.php$ 
RewriteCond %{REQUEST_URI} !^/php.php$ 
RewriteCond %{REQUEST_URI} !^/allJS\.php?v2$ 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule ^ %1 [R,L,NC]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-12-12
@VPVPVP

well, it’s easier to say what’s so here
1. I wrote a standard .htacces and everything was thought out in it, you cut out pieces from it, stuck it in different places and ask what went wrong here.
For example, you have only one piece responsible for removing the slash, and your lordship decided not to add a slash to the directories because it was not fate?
2. htaccess is read from top to bottom and sequence is important
3.

upper to lower case, etc.
you also mixed the rules.
Well, here, so that without swearing, I will answer briefly Linux is a register-sensitive system (this is real if swearing and foam) what kind of "smart" person generally came up with making such redirects deserves a separate place in hell.
4.(Chrome/76.0.3809.10) - only this version, the others are not?
5.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

I understand that you tried to remove slashes from symlinks and files?
6. #RewriteCond %{REQUEST_URI} !^/$
uh, it doesn’t bother you that there are no such links in nature
; the domain closes with a slash before the rewrite wheel, that is, it should be site.ru//index.php
in general, you only have part of the CNC engine correctly and it’s strangely divided in the middle,
write that you have for the engine and what you wanted to get with these redirects, I will write you how it should look

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question