V
V
VPVPVP2021-07-20 08:50:13
htaccess
VPVPVP, 2021-07-20 08:50:13

How to remove the slash at the end of the URL in this htacess?

How to remove the slash at the end of the URL in this htacess?
For links to be of the form site.ru/page1 , not site.ru/page1/
RewriteEngine On

# The directive includes redirects !!!!
RewriteBase /
# Without the directive "(.*) = /$1" will be /var/wwww/site/web/$1 with the directive = /$1
Options +FollowSymLinks
# Allows following symbolic links.

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

#RewriteCond %{HTTPS} !on
#RewriteRule ( .*) https://%{HTTP_HOST}%{REQUEST_URI } [R=301,L]

RewriteCond %{THE_REQUEST} //
# Check if slash (//) is repeated more than twice.
RewriteCond %{QUERY_STRING} !http(s|)://
# Make sure it's not a url in GET
RewriteRule .* /$0 [R=301,L]
# Eliminate all unnecessary slashes.
RewriteCond %{REQUEST_URI} \..+$
# If the file contains a dot.
RewriteCond %{REQUEST_FILENAME} !-d
# And it's not a directory.
RewriteCond %{REQUEST_FILENAME} -f
# Is a file.
RewriteCond %{REQUEST_URI} ^(.+)/$
# And there is a slash at the end of the URL.
RewriteRule ^(.+)/$ /$1 [R=301,L]
# Remove slashes.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2021-07-20
@shambler81

I created this file with indents ;)
This is how it looked at the beginning
https://klondike-studio.ru/standards/standartnyy-h...
I think here you can easily figure out what is responsible for what.
pay attention that there are two rules at once and adds and deletes
Depending on whether it is a directory or a file.
so if you need to remove then remove two rules at once.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question