Semantic URL
The term semantic URL refers to a URL which is of a meaningful, human-manipulatable form. Semantic URLs have become an issue in recent years with the increasingly prevalent use of server-side scripting to power websites.
Non-semantic URLs
A non-semantic URL is typically composed of a path, script name, and query string. The query string parameters dictate the content that is to be shown on the page, as in the following example:
http://example.com/showproduct.cgi?prodid=3448
Problems
The key issue with non-semantic URL is that while the query string parameters can be manipulated by hand, it is not always obvious what their possible values are. For example, many content management systems use a database record number to specify the page. This has a logical meaning only to the database management system, meaning page URLs cannot be inferred by users.
Also, if the site database is moved to a different location, or the site itself is ported to a different software, all URLs can change, due to database records being re-ordered, different script file names and/or extensions, and so on. This can cause numerous problems, such as broken links (both internally and from external sites) and removal of search engine listings.
How a semantic URL works
A semantic URL replaces long query strings with a simple, traditional path structure. For example, the URL shown above could be replaced with the following:
http://example.com/products/example-product
The implementation of this can vary, but most often involves transparently rewriting the semantic URL into the query string form which is understood by the server-side software. Because the rewriting takes place on the server side, the semantic URL form is the only form seen by the user.
Key points
The URL is...
- meaningful to the end-user;
- easy to remember or infer;
- independent of the actual server-side software.
External links
- mod_rewrite Apache URL rewriting module.