How to Create a Dynamic Static Website
Once, all the Web was static, mainly HTML pages with lines of text and images spattered about. Every page had its own distinct URL. Then came dynamic pages. Now the Internet is brimming with interactive sites generated from databases. Every blog and online store uses dynamic code, but many of them suffer from a common problem---dynamic sites often have ugly, mangled URLs. What many users want is a site that combines both dynamic and static aspects. While this isn't any easy process by any means, and requires some Web-scripting knowledge, the result can be worth the effort.
Instructions
-
-
1
Learn PHP and MySQL. The PHP programming language and the MySQL database system are two of the most common resources used in the creation of dynamic websites, so this knowledge will serve you far beyond the project immediately at hand. The books on the subject published by O'Reilly and SAMS are some of the best tools to help you learn the essentials, though online tutorials can be helpful, too.
-
2
Install PHP, Apache and MySQL Community Server. Set up your PHP development environment and create a MySQL database and user account. If you own Dreamweaver, you can follow the dynamic website tutorial on Adobe's website and use the program to simplify the process (see Resources).
-
-
3
Enter the PHP code to display and collect data, following your plans for the site. This will vary widely depending on what sort of site you desire, and requires a good grasp of the language to put into action.
-
4
Create a text file named ".htaccess" and save it in your site's root directory. To make a specific page's URL appear as if it were static, place the following two lines of code into the file:
RewriteBase /scriptfolder/
RewriteRule ^staticpage\.htm$ dynamicscript.cgi [T=application/x-httpd-cgi]This tells the site to look in the directory named "scriptfolder" for your scripts, then to display the script "dynamicscript.cgi" as "staticpage.htm". If you want all your pages to appear to be static, instead of just a few specific pages, enter the following line instead:
AddType application/x-httpd-php .htm
Now you can give all your PHP scripts the extension ".htm," and they will appear to users to be static pages, while still being interpreted by PHP.
-
1