.htaccess – Убираем дубли страниц
Как убрать из урлов index.php, index.htm и index.html
Дубли на сайте, это чуть ли не первая вещь на которую вам укажут сеошники после аудита сайта. Поверьте, такая ситуация встречается очень часто, и всё что нужно сделать, это настроить некоторые правила обработки адресов. Для этого добавляем в наш файл .htaccess следующий код:
Вот и всё, прощайте дубли .
Как сделать редирект с сайта без www на сайт с www
Без лишних слов, рассмотрим как сделать редирект на своем сайте:
Теперь, сделаем обратную процедуру – редирект с WWW на без WWW:
Надеюсь у вас всё заработало, а если нет, уточните у вашего хостера, включена ли обработка файла .htaccess.
Убираем .html, .php и .htm в конце URL-адресов на Apache/Nginx
Часто слышу, что сеошники советуют убирать окончания .html, .php и .htm в адресах ваших сайтов – якобы, это негативно влияет на продвижение. Кто-то же говорит, что это просто визуально добавляет адресу лишний мусор.
В любом случае, убирать или оставлять эти окончания, решать вам, я же покажу, как это реализовать на статичном сайте (то есть сайте, находящемся не на CMS). Почему только на статичном? Потому что для различных CMS это реализовывается разными методами, о которых я также расскажу в последующих статьях.
Не утверждаю на 100%, что этот метод не будет работать на какой-то из CMS – пробуйте и о результатах отписывайтесь в комментариях.
Убираем .html, .php и .htm на Apache
Как вы знаете, в Apache существует файл .htaccess, который содержит в себе набор настроек и конфигураций сервера. С его помощью мы и будем убирать ненужные нам окончания.
1. Подключитесь к сайту по FTP и в корне сайта найдите файл .htaccess. Откройте его. Если такой файл отсутствует – создайте.
2. Найдите строчку, содержащую:
Сразу после нее вставьте следующие правила.
Если вам необходимо убрать .php:
Если вам необходимо убрать .html:
Если вам необходимо убрать .htm:
Если строчка «RewriteEngine On» отсутствует в файле – добавьте ее в самое начало.
После чего сохраните изменения и отправьте файл обратно на сайт. Если раньше адреса на вашем сайте были вида
то теперь вы можете открыть эту страницу по адресу:
Убираем .html, .php и .htm на Nginx
1. Для того чтобы подобную настройку произвести в Nginx, откройте файл конфигурации по адресу:
в FTP (если вам позволяют права) либо через панель управления сервером.
2. Далее, в секцию location / <…>, вставляем необходимые правила.
Если вам необходимо убрать .php:
Если вам необходимо убрать .html:
Если вам необходимо убрать .htm:
Если в процессе настройки у вас что-то не получается – пишите об этом в комментариях.
Removing the index.html from url
Ok, maybe a pretty dumb question but I can’t find an answer on Google.
I am coding my site by hand. How do I make the index.html disappear from the url’s? Do I use a piece of code in my html? Do I have to change my href’s in my files?
Hope you guys can help!
EDIT: I’ve tried this with a .htaccess file
RewriteEngine On RewriteRule ^index\.html$ / [R=301,L] RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
It does work, but all my links aren’t working anymore. I discovered I had to remove all the index.html from the href’s in my documents. But that would be a lot of work. Is there an other code for .htaccess that just hides index.html?
8 Answers 8
A SIMPLE WAY TO DO THIS in Html:
(example in my case is a simple dual language site)
If your link looks like this:
You should change it to this:
If trying to link to another folder in your directory, like is my example:
You should change it to this:
Notice that «/» goes back to your root directory and automatically selects index.html, so that is why I used «en» for the English language site, because the name of the folder in that case is «en». You should also make sure that you have index.html in your English language folder, and not index-en.html.
Apache has .htaccess files and mod_rewrite, In your .htaccess file, set:
You can also set this up in the Apache site config files too
You can specify a list of filenames, so if it doesn’t find the first it moves to the next.
![]()
mod_rewrite module is responsible for all the rewriteEngine. Check on your server whether is module is present and enable.
![]()
You need to create a file called ‘.htaccess’ in the root directory of your site containing the following code:
And then make sure all the links on your site don’t contain ‘.html’ at the end, e.g.:
should be replaced with:
Hope this helps!
if you dont find .htaccess, you just need to create a new file using your text editor the same way you would any other html or css file, but save it as simply ‘.htaccess’
And save it into the root directory, so the same folder that you have your index.html file.
![]()
I think this is configured in IIS when you deploy the site, I’m not to sure on it but I’m sure you can specify a start point that your URL will use when you just enter the UL, that implies the Index.html page.
Sorry I’m not too helpful here, hopefully it will point you in the right direction.
Often these things such as Apache or IIS have this set up already, and it looks for the Index.html , Index.php first when you just put your URL in.
![]()
Great SEO idea! This is similar to nginx redirect loop, remove index.php from url and Apache .htaccess to hide both .php and .html extentions, as well as mod_rewrite not working htaccess — the idea here, for both Apache’s mod_rewrite and nginx ngx_http_rewrite, depends on the differences between the external and internal URLs — in order for the redirect from /index.html to / work, yet not cause redirect loops when actually serving index.html , you gotta make sure you only issue the redirect for external index.html requests, but never for internal ones; this can only be accomplished by looking into the actual request_uri .
Here’s the code for nginx ngx_mod_rewrite:
On Apache’s mod_rewrite, it’ll be something like the following:
Change the link that goes to your homepage to the website address. You may have:
Как убрать index.html из URL?

Для начала, на всякий случай, вопрос: вы убираете index.html или index.php?
Для первого пробуйте вот такое, не забыв про http/https:
- Вконтакте

Тут уже не могу не спросить (т.к. лучше спросить, чем нет): а ты точно знаешь, что делаешь?