Answer the question
In order to leave comments, you need to log in
How to compose RewriteCond for .htaccess?
Good Friday evening everyone.
Help compose a rewrite for htaccess so that a slash is added at the end if it is not there, but at the same time, for links like /url.json, it is no longer necessary to add it.
For example:
site.ru/any/url >> site.ru/any/url/
site.ru/any/url/ >> site.ru/any/url/
site.ru/any/get.json >> site.ru/any/get.json
Answer the question
In order to leave comments, you need to log in
Hello, try this
.htaccess
:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(/|.json)$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1/ [R=301,L]
What if you try something like this? Specifying in the regular expression, what if there is a dot at the end and after it from 2 to 5 characters?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(/|.[a-zа-я]{2,5})$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1/ [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question