Website Updates

I've been working on updating this website so that it was a little more easier for people to type and share URLs (if it was needed). Though, I don't know how many people would actually be sharing these links - it's been quite some time since I've actually written anything of value.

Friendly URLs

There's always been some debate online whether "friendly" URLs (also called "SEO URLs") work for SEO. But one thing is for certain that these URLs are more human friendly than anything. The old structure of URLs for this site were (and technically still are because this is how it works under the hood) index.php?view=article&slug=article-name. This URL structure looks pretty ugly to people. It makes perfect sense to the application. View = page or article. This tells the application what we're loading. There are very little technical differences between a page and an article. I might change this in the future. The slug is the "name" of the article or page. For example, this article's slug is webupdate. That helps the program find the correct page or article to load.

To make the URLs friendly to people, we have to do some web server magic. In reality, if we don't tell the server what the URLs are, it is going to look at /article as a directory and not a parameter of the URL. We tell the server about this "fake" URL by using Apache's .htaccess rules. For example:

RewriteEngine On

# Rewrite /article/slug to /index.php?view=article&slug=slug
RewriteRule ^article/([a-zA-Z0-9_-]+)$ /index.php?view=article&slug=$1 [L,QSA]

# Rewrite /page/slug to /index.php?view=page&slug=slug
RewriteRule ^page/([a-zA-Z0-9_-]+)$ /index.php?view=page&slug=$1 [L,QSA]

The comments should help you understand what we're doing. We're also doing some regex here. You can see that we're "rewriting" the URL to what the server knows and understands. So when you are loading this page, what is really being passed to the server is:

index.php?view=article&slug=webupdate