Miscellaneous Topics

How did you make the url system and made pages look like folders instead of scripts

You propably noticed the way the pages on GFXartist are named. Instead of calling:

http://www.gfxartist.com/community/member_gallery.php?artworkID=3264

pages are called as followed:

http://www.gfxartist.com/community/member_gallery/3264

There are 2 options to do this, both having their pro's and con's.

The first method is commonly known as URL-rewriting. A special module is installed in the web server apache which (what's in the name) 'rewrites' the URL of the request. So if you submit "/community/member_gallery/3264" the script rewrites this to /script.php and in this script you can retrieve the origional URL from the envoirment variables.

More info

Pro's

  • Configurable
  • Everything is possible

Con's

  • Very complicated configuration and installation
  • Exceptions have to be made for dir's which should not be rewritten (like images)

The second method I stole from a collegue of mine: Fabian Kranen, he showed me a rather interresting feature of the 404-error page. We put a simple configuration option in a .htaccess-file in the root of the site (or the apache config) All the file contains is:

ErrorDocument 404 /index.php

This makes that for all non existing pages which are called the index.php is executed. In this index.php we have to fix some thing in the header because apache automatically sends the "404 document not found" response to the client. To fix this we start the php code with:

header ("HTTP/1.1 200 OK");
header ("Status: 200 OK");

Now the error codes are overwritten and internet explorer will not show the "friendly" error message instead of what you output in the script. This trick is used on GFXArtist. So the point is: All the pages you see when you browse GFXArtist don't really exist ;)

More info

  • There is no info about this on the web as far as I know. (sorry)

Pro's

  • Really easy and straightforward to use

Con's

  • Apache sees every page as an error, so turn error logging off if you don't wan't the logs to be flooded with 'errors' (error logging has no use anyway because none of these methods writes any errors to the log if a page doesn't exist.
  • POST request will lose their posted data, so all pages will have to be called with just GET data. (we fixed this problem by using seperated actions which can be called with POST and GET vars and allways send you back to another page on the site
Search the site
SiteSearch

Web GFXartist.com

Affiliates