N
N
Normant2017-05-23 00:58:02
Apache HTTP Server
Normant, 2017-05-23 00:58:02

How to remove slash and empty data from .htaccess?

Tell me how to remove empty values ​​from the URL using .htaccess, both at the end and in the middle.
For example: site.ru/slovo1//slovo3 should redirect to site.ru/slovo1
And site.ru/slovo1/ to site.ru/slovo1
Now I use the following configuration:

DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =off 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?do=$1 [L,QSA]

RewriteCond %{HTTP_HOST} !^mysite\.ru
RewriteRule ^(.*)(/)$ http://mysite.ru/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP
RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L]
AddDefaultCharset utf-8

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-05-23
@shambler81

RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question