websites urls without file extension?

后端 未结 10 1675
误落风尘
误落风尘 2020-12-16 14:50

When I look at Amazon.com and I see their URL for pages, it does not have .htm, .html or .php at the end of the URL.

It is lik

相关标签:
10条回答
  • 2020-12-16 15:05

    For websites that use Apache, they are probably using mod_rewrite that enables them to rewrite URLS (and make them more user and SEO friendly)

    You can read more here http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html and here http://www.sitepoint.com/article/apache-mod_rewrite-examples/

    EDIT: There are rewriting modules for IIS as well.

    0 讨论(0)
  • 2020-12-16 15:05

    A lot of people are using an more "RESTful" type architecture... or at least, REST-looking URLs.

    This site (StackOverflow) dosn't show a file extension... it's using ASP.NET MVC.

    0 讨论(0)
  • 2020-12-16 15:13

    More specifically than most of these answers:

    Web content doesn't use the file extension to determine what kind of file is being served (unless you're Internet Explorer). Instead, they use the Content-type HTTP header, which is sent down the wire before the content of the image, HTML page, download, or whatever. For example:

    Content-type: text/html
    

    denotes that the page you are viewing should be interpreted as HTML, and

    Content-type: image/png
    

    denotes that the page is a PNG image.

    Web servers often use the file extension if the file is served directly from disk to determine what Content-type to assign, but web applications can also generate pages with any Content-type they like in response to a request. No matter the filename's structure or extension, so long as the actual content of the page matches with the declared Content-type, the data renders as intended.

    0 讨论(0)
  • 2020-12-16 15:15

    Your browser doesn't care about the extension of the file, only the content type that the server reports. (Well, unless you use IE because at Microsoft they think they know more about what you're serving up than you do). If your server reports that the content being served up is Content-Type: text/html, then your browser is supposed to treat it like it's HTML no matter what the file name is.

    0 讨论(0)
  • 2020-12-16 15:17

    Typically, it's implemented using a URL rewriting scheme of some description. The basic notion is that the web should be moving to addressing resources with proper URIs, not classic old URLs which leak implementation detail, and which are vulnerable to future changes as a result.

    A thorough discussion of the topic can be found in Tim Berners-Lee's article Cool URIs Don't Change, which argues in favour of reducing the irrelevant cruft in URIs as a means of helping to avoid the problems that occur when implementations do change, and when resources do move to a different URL. The article itself contains good general advice on planning out a URI scheme, and is well worth a read.

    0 讨论(0)
  • 2020-12-16 15:17

    Depending on the settings of your server you can use (or not) any extension you want. You could even set extensions to be ".JamesRocks" but it won't be very helpful :)

    Anyways just in case you're new to web programming all that gibberish on the end there are arguments to a GET operation, and not the page's extension.

    0 讨论(0)
提交回复
热议问题