I
I
itworlds2019-04-14 08:52:05
htaccess
itworlds, 2019-04-14 08:52:05

Need help with htaccess?

Hello. I need to configure .htaccess to do 2 things:
1. Remove .html from the end of links
2. Redirect from http to https
First there was this code:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^\S+\s+/([^.?]+)\.html
RewriteRule ^  https://site.com/%1 [R=301,L]

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

RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html [L]

But google cursed that there was a redirect, for example, from site.com/1.html to site.com/1 and did not show such pages in the search.
The technical support of the hosting suggested this option:
RewriteEngine On 
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html

But it doesn't strip the .html from the end.
Please tell me how to fix this. The most important thing is that there are no redirects.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2019-04-16
@shambler81

https://klondike-studio.ru/standards/standartnyy-h...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question