0

I was wondering if there is anything wrong with using html and php files without extensions.

For example, if I was to upload a file with an extension, I would get to by using a URL like this:

http://yoursite.com/randompage.html

If I used a file without an extension, I would use a URL like this:

http://yoursite.com/randompage

I know that this can't be the preferred method because it leaves the file without a way to be identified, but is there anything that would stop the site from working properly?

Olokoo
  • 1,114
  • 3
  • 19
  • 34

3 Answers3

2

What you want to do is done with url-rewriting .

Basically, you will add a rewrite rule to your web server, so when he receives a request for url yoursite.com/randompage he will change it to yoursite.com/randompage.html. You will find a lot of examples on the web if you google for "mod_rewrite examples" or "url rewrite examples".

Nelson
  • 49,283
  • 8
  • 68
  • 81
  • I'll delete my answer. Ya just do it this way. It allows you to be really specific and have more control over your urls. – Parris Sep 21 '12 at 20:21
  • So when I do this, it does not show, "yoursite.com/reandompage.html" and will only show, "yoursite.com/randompage"? – Olokoo Sep 21 '12 at 20:28
  • Yes, the url the browser will display in the address bar will be 'yoursite.com/randompage'. If you look at this site, stackoverflow.com it doesn't have any link with an ending extension thats because it uses url-rewriting too. – Nelson Sep 21 '12 at 20:33
1

Document types are sent from the webserver in http headers, so it is perfectly possible to do what you are asking.

For instance when using Apache, to tell it that any file with no extension is html, in the 'conf' file you can say:

DefaultType text/html

More details at Apache The Definitive Guide

Bryan
  • 11,398
  • 3
  • 53
  • 78
0

This point to concrete document (randompage.html in this case):

http://yoursite.com/randompage.html

This point to default document in directory:

http://yoursite.com/randompage/

Default document is set in you webserver. This could be for example: index.html, default.html, index.php, default.apsx,...

eridanix
  • 818
  • 1
  • 8
  • 27
  • The questionner didn't have a '/' at the end of his URL. This answer is wrong. – Bryan Sep 21 '12 at 20:28
  • If you read the question carefully, you will see he is asking about _uploading_ a _file_ with no extension. – Bryan Sep 21 '12 at 20:36