Submit Your Article Forum Rules

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: html file w/ no file extension

  1. #1
    Senior Member
    Join Date
    Aug 2007
    Location
    Manitou Springs, Co
    Posts
    121

    html file w/ no file extension

    Hello,

    Does anyone have an idea of how wikipedia makes files without file extensions open in browsers correctly.

    If I create a HTML file and save it without the file extension .html it will open correctly in Internet Explorer but not in Netscape or Mozilla.
    Website design & development by Hidden Content .

  2. #2
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    2,981

    Re: html file w/ no file extension

    This is done server side, you need to set the mime type of the file through .htaccess if it is an Apache server. However, I would not be suprised if the wiki system used mod_rewrite to change /some_entry to /showEntry.php?s=some_entry. Because Apache knows what mime type to send for the PHP file, no modification has to be made, even though the outside user doesn't see the extension.
    The best way to learn anything, is to question everything.
    Hidden Content

  3. #3
    Junior Member
    Join Date
    Feb 2008
    Posts
    23

    Re: html file w/ no file extension

    Quote Originally Posted by wige View Post
    This is done server side, you need to set the mime type of the file through .htaccess if it is an Apache server. However, I would not be suprised if the wiki system used mod_rewrite to change /some_entry to /showEntry.php?s=some_entry. Because Apache knows what mime type to send for the PHP file, no modification has to be made, even though the outside user doesn't see the extension.

    really? can you give some example...

  4. #4
    Junior Member
    Join Date
    Apr 2006
    Posts
    13

    Re: html file w/ no file extension

    It is actually pretty easy. We do it as well. Makes for nice clean URL's.

    The problem with giving examples is there are different requirements for different versions of apache.

    But you will basically want to create a PHP file that will pull information from your database. From there you will want to save the file without a file name. For example:

    test.php would be saved as just test.

    From there you would put a set of lines like this in your .htaccess file or in your httpd.conf file if you had access to that:

    <Files test>
    ForceType application/x-httpd-php
    </Files>

    Now your test file would need to parse the URL properly and then use the extra "directories" to pass as parameters to the query or whatever else you wanted to do. Such as this:

    www.test.com/test/var1/var2/var3

    $chunk = explode("/", $_SERVER['PATH_INFO']);

    Then you can reference each different variable as:

    $chunk[1] = var1
    $chunk[2] = var2
    $chunk[3] = var3

    etc..

    From there just use that information as parameters in your Query so you pull the right data from your database.


    It is pretty easy and there is a tiny bit of information on the web relating to this, but it is out there.

    Good luck,

    Fred

  5. #5
    Junior Member
    Join Date
    Nov 2007
    Posts
    6

    Re: html file w/ no file extension

    if you make a folder names say "specials" and have a index.html file in there you can link to say:

    h t t p ;// yourdomain.com/special

    you will see the contents of that index.html
    If you would want it to go to another location, just put a redirect in that index.html

    It is a simple solution but it works.

  6. #6
    Member PaulMycroft's Avatar
    Join Date
    Jul 2007
    Location
    Ladysmith, B.C.
    Posts
    79

    Re: html file w/ no file extension

    Quote Originally Posted by kruser View Post
    If I create a HTML file and save it without the file extension .html it will open correctly in Internet Explorer but not in Netscape or Mozilla.
    I *think* Kruser is asking how a web page with no suffix appears in some browsers but not others, not how directory and default pages are handled? Correct me if I am wrong.

    If you are asking how a web page that should be called "www.domain.com/pagename.html" but is called "www.domain.com/pagename" (not a directory), the answer is that some browsers are more forgiving than others.

    For example, if you do not close a tag correctly in a web page's code (e.g. a table cell), that page will break in some but not other browsers.

    Hope that helps.
    All the best,
    Paul Mycroft
    Hidden Content

  7. #7
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    2,981

    Re: html file w/ no file extension

    Quote Originally Posted by PaulMycroft View Post
    If you are asking how a web page that should be called "www.domain.com/pagename.html" but is called "www.domain.com/pagename" (not a directory), the answer is that some browsers are more forgiving than others.
    This is somewhat the case, but there is another factor on the server side. Wikipedia for example does not use file extensions, but all of their pages display properly in all major browsers. The reason is that the file extension is irrelevant on web documents. The server includes a header that tells the browser how the file should be rendered - as an image, a text file, a pdf file, a web page, etc. If you do not take special measures to cause the server to label files without extensions as web pages, the server will say that they are plain text. Some browsers will display plain text files containing HTML as web pages, others display the files as plain text.
    The best way to learn anything, is to question everything.
    Hidden Content

  8. #8
    Senior Member
    Join Date
    Aug 2007
    Location
    Manitou Springs, Co
    Posts
    121

    Re: html file w/ no file extension

    Very Cool...

    As per the suggestions:

    I created a .htaccess file with one line:
    ForceType application/x-httpd-php

    uploaded .htaccess to test directory

    then I created an html file and saved it with out a file extension to the test directory


    It works!!!

    Thanks for the cutting edge information everybody!!
    Website design & development by Hidden Content .

  9. #9
    Senior Member
    Join Date
    Aug 2007
    Location
    Manitou Springs, Co
    Posts
    121

    Re: html file w/ no file extension

    Does the .htaccess line
    ForceType application/x-httpd-php

    Does that mean the browser will see the file as a php page?


    Then would:
    ForceType application/x-httpd-html

    the browser see as an html?
    Website design & development by Hidden Content .

  10. #10
    Senior Member
    Join Date
    Jul 2004
    Posts
    884

    Re: html file w/ no file extension

    Quote Originally Posted by kruser View Post
    Then would:
    ForceType application/x-httpd-html

    the browser see as an html?
    'ForceType text/html' should do that.
    Impossible? You just underestimate the time.Hidden Content

Similar Threads

  1. File Extension / File Suffix in SEO
    By Ladana in forum Search Engine Optimization Forum
    Replies: 6
    Last Post: 07-10-2008, 05:56 PM
  2. Windows 2000 Slow with File Open and File Save Dialog Boxes
    By steve0 in forum IT Discussion Forum
    Replies: 2
    Last Post: 09-15-2005, 05:27 PM
  3. Dreamweaver: Error accessing file...bad file path
    By mimsymc in forum Graphics & Design Discussion Forum
    Replies: 6
    Last Post: 07-10-2005, 08:43 PM
  4. Do you know about file extension FLM
    By kiumars in forum Graphics & Design Discussion Forum
    Replies: 7
    Last Post: 04-10-2004, 05:45 AM
  5. changing file extension on home page
    By iain in forum Search Engine Optimization Forum
    Replies: 5
    Last Post: 03-29-2004, 08:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •