Forum Moderators: coopster

Message Too Old, No Replies

Need a dynamic page with .html extension

Page contents taken from a database

         

chodges84

12:34 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



Hi,

I don't know if this is possible but heres the story.

I run an ecom site, and currently all the pages are done by hand. if i add a new product I just load up the template, put the product details in, and a buy link (just a html link, which takes them to my cart, not Paypal cart btw).

However, I would like it if I could pull the contents from a database, basically the site is getting bigger, and I've ot something planned, that will be easier enough to do by hand, but maintaining will be hard and it would just be a lot easier from a database.

I don't want to chage my file system or get stung for having duplicate content, which would happen if I changed my files to .php.

What I would like to know is whether there is any way of pulling content from a SQL database,but maintaining the .html extensions?

Thanks in adavnce

lobo235

12:41 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



Yes, many web hosts allow you to do this or if you run your own server you can set it up easy enough. The way that this is typically done is by adding a line in the apache config file or in the .htaccess file.

AddType application/x-httpd-php .php .html

It will vary depending on how the host wants you to do it but try that for starters.

Another way that some people do this is with mod-rewrite. They rewrite all the html pages to php pages. I prefer using the apache config method myself.

chodges84

6:13 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



Hi Lobo,

Thanks for your reply - much appreciated.

I actually use a shared server - where I pay £20 a year and get 100mb space, 3gb bandwidth p/m etc.

So would the apache config file be accesible, or would my hosting company be able to do this.

So if i have a page called

blue-yellow-widgets.html

and my page was created on the fly from a data base called

blue-yellow-widgets.php

then the apache code thing would change it back to

blue-yellow-widgets.html

and the search engines (or anyone for that matter) wouldn't know it was happening.

Sorry to sound like a dim nut, but this side of things isn't where I usually dabble, so you're help is much appreciated.

lobo235

6:31 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



If you are on shared hosting you won't have access to the apache config file but you may be able to use a .htaccess file so I recommend that you contact your host to see how they can help you out. In the .htaccess files you can either use the mod_rewrite module to just tell apache to internally forward the .html files to their .php versions. If you just add the
AddType application/x-httpd-php .php .html
line then what it does is run every .html file through php so if there are any
<?php?>
tags in the .html file they will get parsed by php.

chodges84

7:13 am on Oct 19, 2005 (gmt 0)

10+ Year Member



Ok Thanks,

One last thing.

I can't see that these pages can be created on the fly, as they will be called

www.mydomain.com/catalogue/blue-yellow-widgets.html

If that page doesn't physically exist, then the user will get a 404.

A lot of dymaic pages i see are something like catalogue.php?Blue-Widgets, so you'll obviously get the right page.

Will the database have to create a page called blue-yellow-widgets.html, and then take the info from a database when the page is called on? Or is there some way it can be 'crated on the fly', as in when a user comes to the page.

Thanks again.