สำหรับคนที่เขียน php เองให้นำเอา class ของ seo url tools นี้ไปใช้งานได้เลยครับ
เจ้าของเค้าแจกฟรี http://seo-url-tools.datavoyage.com
ดาวน์โหลดไฟล์ได้ที่เว็บไซต์เค้าเลย
http://seo-url-tools.datavoyage.com/download-Downloads
This is an quite simple PHP class that fulfills most of the Search Engine Optimization URL needs. Programmer may easily include this library and start developing site that fully supports pretty url’s. He may even customize the way how url’s are handled. All he has to do is to learn few simple rules on handling and manipulating URL’s.
When you use SEO URL TOOLS you do not create links in documents on your own. You define contents of the URL and then let this library to create actual url. Means to define URL’s are simple and straightforward, and what is more important, it is uniform way to create any URL on your site. If you follow this principle, all URL’s on your site will follow the same syntax rules and site would provide to you everything you need to know which document to load and what parameters are sent to that document.
SEO URL TOOLS library is free for noncommercial use.
How to install?
Place class_seo_url.php into root folder of the site.
Then you have to turn on and set rewrite engine for your site. Make sure that Apache has rewrite engine module installed and place simple .htaccess file in the very root of your site. Contents of the file is:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
That would instruct Apache to rewrite all URL’s to index.php in root of the site. The simplest index.php could be like this:
<pre>
<?php
include ('class_seo_url.php');
$seo = new seo_url_tools();
$m_url = $seo->get_current_url();
echo "Current url as string: $m_urln";
$m_url_array = $seo->get_current_url('array');
echo "Current url as array: n";
print_r ($m_url_array);
echo "n";
?>
</pre>
It will show you parsed URL’s accepted through rewrite engine. It does not use SEO url’s yet, but it is fine to check if rewrite engine works. Play with it. Type in various addresses in your browser and watch how they are parsed as parameters. Type addresses with various number of directories in path, type in query parameters and see what you get.
Now, lets turn SEO URL’s on. Alter this script by adding one new line to turn SEO mode on (changed line is $seo->set_pretty_url_mode (true);):
<pre>
<?php
include ('class_seo_url.php');
$seo = new seo_url_tools();
$seo->set_pretty_url_mode (true);
$m_url = $seo->get_current_url();
echo "Current url as string: $m_urln";
$m_url_array = $seo->get_current_url('array');
echo "Current url as array: n";
print_r ($m_url_array);
echo "n";
?>
</pre>
Repeat entering various addresses and see how url’s are interpreted now.
Credit: http://seo-url-tools.datavoyage.com