# Dynamic websites with .html extension?



## FredT (Nov 16, 2007)

Hi,

I'm always curious when I come across a site that is obviously dynamic (a forum or something) but has a .html/.htm extension. I'm thinking this could be done one of two ways... ajax, but I've checked the source and that isn't the case, or some other server-side scripting language that I am not familiar with.

You can tell when a site is using a language like asp or php or even jsp or cfm based on its extension. But I've never seen a site that shows it is using ruby on rails or perl or some other language like that... I have absolutely no idea how either of these languages work, but is that what is going on? Do they output .html pages?

I would really like to know because I am looking into creating a site where people can create profiles and I would rather have them be able to access it by

www.something.com/users/myuser.html

than

www.something.com/users.php?user=myuser

Thanks!

Edit - P.S. I've also seen sites even put "get" variables in the url with an html extension... like this:

www.mysite.com/something.html?myvar=32


----------



## dm01 (Oct 10, 2006)

You can do this, if you have the appropriate permissions. The exact method depends on what host you choose.

Once you have figured out your host, post back and we'll give you the method you should use.


----------



## jamiemac2005 (Jul 5, 2007)

> ...I have absolutely no idea how either of these languages work, but is that what is going on? Do they output .html pages?...


Generally the server will parse the page(look for server side code) then send HTML code to the user which the browser interprets. Usually the extension isn't htm/html though it can be set to anything.

As for seemingly dynamic pages they'll always be some form of scripting language behind it(as you've mentionned AJAX and server-side languages)... Usually this depends on the developer's experience and ideas. For example this forum quite obviously uses AJAX[i think, i haven't checked] in the quick reply section(because it changes the page without re-loading)...

As for GET variables in .html pages, this could be because the server's set up to parse .html files as a server-side language(as said above) or it could be parsed using Javascript.

It really is up to the developer and their way of thinking.

Cheers,
Jamey


----------



## FredT (Nov 16, 2007)

Thanks for the responses.



> Once you have figured out your host, post back and we'll give you the method you should use.


My host is lunarpages (linux) if that's what you're talking about.

And the forum I was referring to is here. Notice how the extension on the website is .htm? They didn't use ajax to grab those posts, they are right in the source code... no ajax.

Also, my teacher uses this utility to post his homework assignments for the week, but I just used some random person listed under "Smith" as an example to show you guys. See how this person's personal page is an actual html file with their name as supposed to having to use "get" variables.

And how does the server parse html as server side code? Does that mean I could set my server to think of html files as php files?

And how would it "create" the new page? The fully automated system my teacher uses creates the teacher webpage... myname.html

Does this make sense?

Thanks


----------



## dm01 (Oct 10, 2006)

I didn't get anything in the above, except that your host is Lunarpages. Lunarpages uses Apache, so we will proceed as an Apache server.

First of all, you need to open your WWW root directory. This is usually found at path: /home/username/public_html . Find a file called .htaccess. Copy this file to your Desktop. Make a copy of this copy, and call this one .htaccess_old.
If you don't have a file called .htaccess, create a new file called .htaccess (no extension). Open your Desktop copy of .htaccess using Notepad. and copy the following into your .htaccess file:

```
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
```
Save the file, and after confirming you did not delete anything, upload .htaccess to the root directory, replacing the current file if necessary. If you did change the file in a way you were not supposed to, you can re-copy the text from .htaccess_old and start over.

Delete .htaccess_old. Keep .htaccess with your other site files in case of server crash or other catastrophic event.


----------



## FredT (Nov 16, 2007)

Is it normal that my .htaccess file is empty? It is just a blank file.


----------



## FredT (Nov 16, 2007)

And also, what I was trying to say was... let's say I sign up for an account at Quia. I create my little profile. Great. It is at quia.com/pages/mypage.html

How did mypage.html get created? It wasn't there until I signed up and said that I'd like my profile to be named "mypage".

If I were to try and make a site like this right now, I would have it at quia.com/users.php?userid=mypage and then access a database and try and grab the info about the user "mypage" and display it.

But with quia's site, I sign up for my account and a new page is automatically generated just for me :smile:

Does it make sense this time? Reading it back it sounds confusing, but I don't know how else to explain it.

Edit: And the code you gave me for the .htaccess, does that mean that every file I make with a .htm or .html extension will be parsed as if it were named with a .php extension?


----------



## dm01 (Oct 10, 2006)

Automatic generation of pages depends on what codes you have on the site. I don't know much about side-scripting or server scripting.

With the .htaccess code I provided, all HTML, CSS, and PHP will be parsed. If the code wasn't in the file, the browser would throw a fit, and maybe crash if you tried to run PHP through a pure .html file.


----------

