SEO URLs without mod_rewrite and FilesMatch
Many CMSs solve the need for Fancy
URLs (URLs that are easy to follow by the user, and favoured by Search
Engines as well) by using
only on Apache), or both.
E.g., to get
$itemid from URL like
need to create following
<FilesMatch "^article$"> ForceType application/x-httpd-php </FilesMatch>
In this example we are forcing
/article/ part of the URL to be
processed as a PHP application.
Next, we will create a new PHP file called
article (without .php
extension), which will process the URL, and determine proper article number,
and pass the control to our CMS.
<?php // some internal function include ('somecommonfncs.php'); // get article id $itemid = getItemIdFromName($_SERVER['REQUEST_URI']); // and process it processIt(); ?>
Seems easy, right? Well, this solution has several big problems in real-life, especially when open-source projects and code portability are concerned.
FilesMatchis not available under Microsoft IIS, it works fine only with Apache, thus this solution may not run at your selected web-hosting company (if they do not use Apache),
- Even if your webhosting company does use Apache HTTP server, you may not
be able to access/create
.htaccess, or it costs you more money to be able to modify it,
- Some browsers (namely, MSIE) behave in a very strange way when downloading
CSS files again for URLs modified in a runtime by
- Google Page Rank (GPR) is different for the domain, and for the article fancy URL, if somebody is linking to your article, it does not even fully add to Google Page Rank value of a domain!
Instead of using FilesMatch, and
.htaccess file, we will use
$_GET variables. Our final URL will look like:
And code will look like:
<?php // some internal function include ('somecommonfncs.php'); // get article id $data=$_GET['article']; if (isset($d)) $itemid = getItemIdFromName($data); // and process it processIt(); ?>
Same approach can be applied for member ids, archivelists ids, category ids, and many others.
This approach does have many advantages and no short-commings:
- This SEO-friendly solution does work with any web-server configuration,
be it Apache, and/or IIS, with or without
- Google Page Rank for your domain increases, even when linking to an individual article,
- Browsers (MSIE) do not reload CSS files again and again,
- You can safely use international characters in URL parameters, thus improving your Page Rank even more.
You can see example of these new fancy URLs at http://demo.blogcms.com/.
BLOG:CMS is an open-source Personal Content Management System, licensed under GNU GPL, developed by Radek Hulán.
Pro přidání komentáře se musíte nejdříve registrovat Facebookem