A
A
alehandroWEB2018-05-07 14:57:54
htaccess
alehandroWEB, 2018-05-07 14:57:54

How to configure .htaccess to add .html extension?

Links like https://mysite.ru/news/aticle should be redirected to https://mysite.ru/news/aticle.html.
This option:

RedirectMatch 301 /news/(.*)$ https://mysite.ru/news/$1.html

from https://mysite.ru/news/article redirects to: https://mysite.ru/news/article.html.html.html.html...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-05-07
@shambler81

RewriteCond %{REQUEST_FILENAME} !-d
# если это не директория
RewriteCond %{REQUEST_FILENAME} !-f
#если это не файл
RewriteCond %{REQUEST_URI} ^.+\.html(|/)$
#Если на конце уже нет .html или .html/
RewriteRule ^(.+)/$ http://www.site.ru/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question