iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-14-2008, 11:06 AM
WebProWorld Pro
 
Join Date: Aug 2007
Location: Stuttgart Germany
Posts: 174
kruser RepRank 1
Default 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.
__________________
Best Regards,
Randy
Reply With Quote
  #2 (permalink)  
Old 02-14-2008, 11:33 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,648
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default 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.
Reply With Quote
  #3 (permalink)  
Old 02-14-2008, 11:43 AM
WebProWorld Member
 
Join Date: Feb 2008
Posts: 26
torpengkute RepRank 0
Default 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...
Reply With Quote
  #4 (permalink)  
Old 02-14-2008, 06:41 PM
WebProWorld New Member
 
Join Date: Apr 2006
Location: Houston, TX
Posts: 13
fbnewtz RepRank 0
Default 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
Reply With Quote
  #5 (permalink)  
Old 02-14-2008, 10:01 PM
WebProWorld New Member
 
Join Date: Nov 2007
Posts: 4
gerard79 RepRank 0
Default 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.
Reply With Quote
  #6 (permalink)  
Old 02-15-2008, 09:28 AM
PaulMycroft's Avatar
WebProWorld Member
 
Join Date: Jul 2007
Location: Ladysmith, BC, Canada
Posts: 55
PaulMycroft RepRank 1
Default 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
Professional Web Design
Reply With Quote
  #7 (permalink)  
Old 02-15-2008, 10:06 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,648
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default 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.
Reply With Quote
  #8 (permalink)  
Old 02-15-2008, 12:32 PM
WebProWorld Pro
 
Join Date: Aug 2007
Location: Stuttgart Germany
Posts: 174
kruser RepRank 1
Default 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!!
__________________
Best Regards,
Randy
Reply With Quote
  #9 (permalink)  
Old 02-15-2008, 01:03 PM
WebProWorld Pro
 
Join Date: Aug 2007
Location: Stuttgart Germany
Posts: 174
kruser RepRank 1
Default 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?
__________________
Best Regards,
Randy
Reply With Quote
  #10 (permalink)  
Old 02-15-2008, 06:56 PM
WebProWorld Veteran
 
Join Date: Jul 2004
Posts: 913
activeco RepRank 2
Default 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.

Last edited by activeco; 02-15-2008 at 07:41 PM.
Reply With Quote
  #11 (permalink)  
Old 02-16-2008, 01:04 AM
WebProWorld New Member
 
Join Date: Nov 2007
Posts: 4
gerard79 RepRank 0
Default Re: html file w/ no file extension

Does this all work with PHP-CGI?
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to converter video file into a flash file ,with effect? andy_lucky Flash Discussion Forum 0 04-04-2006 12:37 PM
Windows 2000 Slow with File Open and File Save Dialog Boxes steve0 IT Discussion Forum 2 09-15-2005 06:27 PM
Dreamweaver: Error accessing file...bad file path mimsymc Graphics & Design Discussion Forum 6 07-10-2005 09:43 PM
Do you know about file extension FLM kiumars Flash Discussion Forum 7 04-10-2004 06:45 AM
changing file extension on home page iain Search Engine Optimization Forum 5 03-29-2004 09:34 AM


All times are GMT -4. The time now is 06:23 PM.



Search Engine Optimization by vBSEO 3.3.0