My Profile Photo


I'm Jason, a web applications developer in the San Francisco Bay area.

Static and Dynamic Resources, and Rewrite Engines

When requesting a single webpage there may be several requests and responses for each resource. A resource being requested may be an HTML coded web page, which then leads to several images which must be requested and loaded inside of the page, as well as other files such as Javascript or CSS libraries needed by the page. This sequence of requests-response transactions which take place between an HTTP client (browser) and an HTTP web server is known as an HTTP session.

Static Resources

Static resources, such as files containing pure HTML coding, are accessed from the server in the same form as they are on the server itself. For example, many web hosting companies provide access to the files on the server via a File Transfer Protocol (FTP) server program that is also running on the web server. The account owner uses an FTP client program such as FileZilla or Dreamweaver to access and upload files to the directory where the website files reside. The FTP account may provide a directory called 'public_html' or 'public', which represents the web root for the public website. Files put directly into this folder will be available directly from the root of the website.

The reason why the folder which contains the website files is a subdirectory of the root folder for the account is so that files which you do not want to be accessed via your website publicly can be uploaded to your account outside of the public_html folder.

For a website using '', a file named 'index.html' can be placed in this directory and will be accessible just by going to . This occurs because the web server is configured to provide any files named 'index.html', as the root webpage for the site. Such a file must be overwritten via FTP with a newer version before the content of that webpage changes for the public. If a folder is created in the 'public_html' directory named 'news', and then a file is placed in that directory named 'updates.html', the URL to access the file would be

Dynamic Resources

Resources provided by a web server may also be dynamic, which means that the contents of the resource/page are generated on-the-fly by coding placed on the server. This type of coding is known as server side scripting because it is executed on the server and influences the response from the web server before it reaches the clients web browser. This is in contrast with Javascript coding which is a client side scripting language that is executed inside of the web browser, commonly used to modify or animate elements of the web page in the browser in real time. HTML and CSS coding are also interpreted by the browser on the client side, but are not technically considered scripting. HTML is a markup language used to describe elements which are rendered on a page, and cascading style sheets (CSS) is a language used to describe the style/presentation of those elements defined by the HTML.

One of the most popular server side coding options available is PHP. Most hosting companies configure their servers to scan files for PHP coding when the files have filenames ending in '.php' instead of the typical '.html' file extension. When found, this PHP coding is executed and dynamically generates certain portions of the page which are provided in the response. This scanning by the web server is also referred to as 'parsing'. This allows PHP coding to be placed in the middle of a file that is predominantly coded in HTML. The HTML coding is provided as is, but the PHP portions of the page are executed and replaced with any text output by the PHP coding.

Although dynamic coding is typically used to output text content such as HTML, CSS, or Javascript coding in a dynamic function, it's possible for scripts to also return images if an image library is in use for a specific purpose. This is less likely, but still possible, which is why I've referred to them as static or dynamic resources instead of static or dynamic web pages.

Rewrite Engines

More advanced website applications do not operate within this paradigm where the URL of a specific resource corresponds directly with specific directories or files on the web server. For instance the Wordpress blogging system relies on an extension of the Apache web server known as mod_rewrite to direct all requests directly to the main index.php file located in the root of the directory which stores the Wordpress system files. The index.php file is programmed to compare the request, such as '/2010/02/how-to-tie-your-shoe' to a list of routing rules which determine which internal resource within the Wordpress system should be served, such as a page or blog post.

This method makes it so that the website URL for each page is within complete control of the web application instead of the web server it is running under. This method allows website developers to specify URL's for each section of the site which enhance the search engine optimization for those pages. For example a system not using a rewrite engine might provide pages dynamically using the following address:

In the above URL 'p=5' is telling the index.php file to provide page ID '5' in the response. Search engines do not prefer to follow links with parameters such as this, as they know all the content is being dynamically fed via scripting driven by a database. They prefer to index pages which were created manually and placed into directories with URL's ending like /about/ or /about/index.html. Rewrite engines make it possible to map such URL's directly to pages which are dynamically generated via your database driven blog, or content management system.

The example page provided by a system using a rewrite engine might provide the page via this URL: