PHP Search Engine Optimization - ForceType
(Page 4 of 4 )
Another way to make dynamic URLs appear static is by using Apache’s ForceType method in combination with a PHP command to interpret URLs like: www.example.com/articles/21/0.html as referring to a page called "articles" which is executed as a PHP script. This can be accomplished by inserting a line like this into the .htaccess file in the root of your web documents directory:
ForceType application/x-httpd-php
Now create a file called "articles":
$nav = $_SERVER["REQUEST_URI"];
$script = $_SERVER["SCRIPT_NAME"];
$nav = ereg_replace("^$script", "", $nav);
$nav = str_replace(".html", "", $nav);
$vars = explode("/", $nav);
$article = $vars[1];
$page = $vars[2];
require("/index.php?act=articles&id=".$article."&page=".$page);
?>
It works in a similar way as the mod_rewrite example does, but with a little more work.
Advantages
One big advantage to using dynamic pages as opposed to static pages is the ability to create content that is constantly changing and updated in real time. You can use the tricks above, combined with RSS feeds from other sites and other automatically “fresh” content to boost your ranks in Google and many other search engines.
Another advantage to using PHP is that you can make simple modifications to many scripts to create relevant page titles. Since this is the most important factor in SEO, special attention should be given to creating title tags that accurately reflect the page’s current content. Any HTML templates that are used in PHP pages can be altered to contain this line:
<title><?=$page_title?></title>
With this, $page_title can be set to a keyword rich text describing the page. Title text is also important in improving the click-through from SERP’s, so be sure that the title tags doesn’t read like spam, but more like a human created title.
Conclusion
Mod_rewrite and ForceType can be powerful tools for any webmaster to add to their arsenal when dealing with PHP. Which methods you want to use are up to you. I’ve employed both in my development for different purposes and they both serve me well.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
|
| · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | | |
|