Я должен поместить .htm в конце своих URL?

В моем случае я захожу на сервис, работающий на моем собственном Mac, поэтому мой URL 127.0.0.1:8080/list

После добавления схемы http: // Это работает!

Теперь это http://127.0.0.1:8080/list вместо 127.0.0.1:8080/list

6
задан Anthony Mastrean 4 June 2009 в 20:55
поделиться

5 ответов

none of the websites I use [put .htm into urls] Why not?

The simple answer would be:

Most sites offer dynamic content instead of static html pages.

Longer answer:

The file extension doesn't matter. It's all about the web server configuration.

Web server checks the extension of the file, then it knows how to handle it (send .html straight to client, run .php through mod_php and generate a html page etc.) This is configurable.

Then web server sends the content (static or generated) to the client, and the http protocol includes telling the client the type of the content in the headers before the web page is sent.

By the way, .htm is no longer needed. We don't use DOS with 8.3 filenames anymore.

To make it even more complicated: :-)

Web server can do url rewriting. For example it could redirect all urls of form : www.foo.com/photos/[imagename] to actual script located in www.foo.com/imgview.php?image=[imagename]

8
ответ дан 10 December 2019 в 00:43
поделиться

Расширение .htm - это мерзость, оставшаяся со времен ограничений на длину имени файла 8.3. Если вы пишете HTML, его правильнее хранить в файле .html. Имейте в виду, что URL-адрес, который вы видите в браузере, не обязательно напрямую соответствует какому-либо файлу на сервере, поэтому вы редко видите .html или .htm где-либо, кроме статических сайтов.

2
ответ дан 10 December 2019 в 00:43
поделиться

Полагаю, вы читаете руководства по созданию статических веб-страниц в формате html. Большинство сайтов динамически генерируются программами, которые используют URL-адрес для определения просматриваемого вами контента. URL-адрес не привязан к файлу. Если таких динамических программ нет, то файлы с URL-адресами являются синонимами.

0
ответ дан 10 December 2019 в 00:43
поделиться

По возможности не используйте .htm (или любое расширение файла). Он ничего не добавляет к использованию сайта и раскрывает нерелевантные детали в URL.

0
ответ дан 10 December 2019 в 00:43
поделиться

There's no need to put .htm in your URL's. Not only does it expose an unnecessary backend detail about your site, it also means that there is less room in your URLs for other characters.

It's true that URL's can be insanely long... but if you email a long link, it will often break. Not everyone uses TinyURL and the like, so it makes sense to keep your URL's short enough so that they don't get truncated in emails. Those four characters (.htm) might make the difference between your emailed url getting truncated or not!

0
ответ дан 10 December 2019 в 00:43
поделиться
Другие вопросы по тегам:

Похожие вопросы: