S
S
Sanekkes2018-09-13 12:27:28
htaccess
Sanekkes, 2018-09-13 12:27:28

How to remove .html from url on website and redirect /uk to /uk/ (to https and without www)?

Hello. How can I set up a redirect on the site from /uk to /uk/ if the file is in the root with the name uk.html? Is it possible to set the page url if, for example, it is in a folder like home-ukrainian.html but it was displayed as /uk/?
Site on https, without www
Now htaccess is configured like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule ( .*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#Remove .html extension
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ %1 / [NC,L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ $1.html [NC,L]
ErrorDocument 404 /404.html

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-09-13
@dodo512

# Редирект с /uk на /uk/
RewriteRule ^([^./]+)$ /$1/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^uk/home-ukrainian\.html$ /uk/ [R=301,L]

RewriteRule ^uk/$ /uk/home-ukrainian.html [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question