M
M
Maxim Kukushkin2020-07-21 05:48:05
htaccess
Maxim Kukushkin, 2020-07-21 05:48:05

How to setup htaccess file?

Hello! I understand that the topic is being eliminated, the Internet is full of information, but still I will ask for help here

There is such a .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?route=$1 [L,QSA]


Here I redirect everything to the index.php page assembler, and by the route value I select the desired page content (already in the php file)

Actually, I need to do 3 more things without breaking this system: redirect from www to without www, redirect from http to https and a redirect from a link with a slash at the end to a link without a slash.

How to do it correctly and without changing the existing logic?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-07-21
@me4t10

RewriteEngine On

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

RewriteCond %{ENV:HTTPS} !on    [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?route=$1 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question