Answer the question
In order to leave comments, you need to log in
How to combine rules in htaccess?
Good afternoon! there is a file in which the following rules simultaneously work:
1) redirect from http to https
2) redirect from without www to www
3) redirect from without / at the end with / at the end
4) redirect from double // to
one redirect
you need to add a redirect from double to single (without creating a chain of redirects
When I add a rule
RewriteCond %{REQUEST_URI} ^(.*)--(.*)$
RewriteRule . %1-%2 [R=301,L]
RewriteEngine On
RewriteCond %{REQUEST_URI} !\?
RewriteCond %{REQUEST_URI} !\&
RewriteCond %{REQUEST_URI} !\=
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !\/$
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ https://www.%1/$1/ [L,R=301]
RewriteCond %{REQUEST_URI} !\?
RewriteCond %{REQUEST_URI} !\&
RewriteCond %{REQUEST_URI} !\=
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !\/$
RewriteCond %{HTTP_HOST} ^([^www].*)$
RewriteRule ^(.*)$ https://www.%1/$1/ [L,R=301]
RewriteCond %{REQUEST_URI} !\?
RewriteCond %{REQUEST_URI} !\&
RewriteCond %{REQUEST_URI} !\=
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} ![^\/]$
RewriteCond %{HTTP_HOST} ^([^www].*)$
RewriteRule ^(.*)$ https://www.%1/$1 [L,R=301]
# DOUBLE / START
RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]
# DOUBLE -- START
RewriteCond %{REQUEST_URI} ^(.*)--(.*)$
RewriteRule . %1-%2 [R=301,L]
Answer the question
In order to leave comments, you need to log in
RewriteEngine On
RewriteCond %{REQUEST_URI} !/$ [OR]
RewriteCond %{THE_REQUEST} ^[^?]+(?://|--)
RewriteCond $1 ^(.*-)-(.*)$|(.*)
RewriteRule ^([^.]+?)/?$ https://www.soskin.com.ua/%1%2%3/ [R=301,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.soskin.com.ua/$0 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question