D
D
Denis2020-12-20 15:36:17
htaccess
Denis, 2020-12-20 15:36:17

Why does the redirect to https not work on self-written cms?

There is an old site on foxline cms. In my own rule was written for removing .php at the end of the url. The problem is that now it is impossible to move to https in any way.

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>

<ifModule mod_headers.c>
  <FilesMatch "\.(html|htm)$">
    Header set Cache-Control "max-age=2592000"
  </FilesMatch>
  <FilesMatch "\.(js|css|txt)$">
    Header set Cache-Control "max-age=2592000"
  </FilesMatch>
  <FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
    Header set Cache-Control "max-age=2592000"
  </FilesMatch>
  <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
    Header unset Cache-Control
  </FilesMatch>
    </IfModule>
  
DirectoryIndex index.php
AddType application/x-httpd-php .js


RewriteEngine On

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

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

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_\-]+)(.*)$ index.php?page=$1 [NC,QSA]




# 09.01.2018 Redirects 404
RewriteRule ^images/catalog/items/thumb/$ /? [L,R=301]
RewriteRule ^single$ /? [L,R=301]
RewriteRule ^favicon$ /themes/freshcold/img/favicon.png? [L,R=301]
RewriteRule ^sistemyi\-komnditsionirovaniya\-i\-klimata$ /sistemyi-konditsionirovaniya-i-klimata? [L,R=301]
RewriteRule ^remont\-oborudovaniya$ /remont? [L,R=301]
RewriteRule ^zapornyie\-ventili$ /ventili? [L,R=301]
RewriteRule ^montaj\-oborudovaniya$ /montaj? [L,R=301]
RewriteRule ^\-1464699812$ /ventilyator_6d-710? [L,R=301]
RewriteRule ^\-1466152458$ /rulony_k-flex? [L,R=301]
RewriteRule ^\-1466152567$ /monobloki-srednej-temperatury-serii-standart? [L,R=301]


I tried many different options, nothing works.

For example, when using this rule
RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$

RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]


Gets error ERR_TOO_MANY_REDIRECTS.
Tell me what can be done about it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yakov Gellert, 2021-01-08
@novusnota

RewriteEngine onTry adding the following after the line :

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

Usually, such a redirect is required if the server has a proxy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question