1
wishcraft
Optimizing URL Path - SEO Tip #4

Well as some of you may be aware I have been writting a few SEO tips and ticks for modules. I am going to use Ben Brown, Fernando Santos & Tobias Liegl - Content module in this example but it works for all modules.

This is about URL Optimization with the use of a .htaccess file.

First Up in this example you can see it at work at a site I have been putting together for SEO'ing XOOPS (http://www.seo-solutions.co.in). This ensures that we have an environment for discussing and maintaining SEO techniques for XOOPS and Websites in general. There are also a few free tools there for you to use.

Ok first up lets have a look at an example .htaccess file

Quote:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9\ \'\_\-]+)$ ../modules/freetools/?menu=$1 [L,NC,QSA]


This htaccess file will rewite the URL when a file or path in the /public_html/freetools path doesn't exist ie. http://www.seo-solutions.co.in/freetools/Position_Checker

You have to alter the index.php file to support a $_GET['menu'] variable which in my code looks like from line 39 to 46 (Orignally on line 39):

$menu = isset($HTTP_GET_VARS['menu']) ? $HTTP_GET_VARS['menu'] : '';
if (
strlen($menu)>0){
  
$result $xoopsDB->queryF("SELECT storyid FROM ".$xoopsDB->prefix(_FTS_freetools_PREFIX)." WHERE title LIKE '$menu'");
  
$rt $xoopsDB->fetchArray($result);
  
$id $rt['storyid'];
} else {
    
$id = isset($HTTP_GET_VARS['id']) ? intval($HTTP_GET_VARS['id']) : 0;
}


orgianlly this code was only one line which was $id = isset($HTTP_GET_VARS['id']) ? intval($HTTP_GET_VARS['id']) : 0;

Now what this is doing is using the content's title field to look up the ID, the underscore '_' in MySQL support a wild card for 1 character which means that it will with a Like command look up the ID and pass it to the remaining code.

This will then reload the page on the example URL i have shown you without the page even being in that folder. There is a couple of limitations in XOOPS 2.0 and 2.2 that is when you can't rewrite the URL in the mainmenu easily... I am looking into this more, the only problem with this is you get 2 URL in the search index for 1 page.. bit like spam isn't it.

This is all to it, if you want to hire me to optimize your xoops, I am available on ad hoc arrangements - $85AUD p/h. btw you may need this function for your sitemap mentioned in SEO Tip #3 it is called SEF it changes a title to a URL consistant with a MySQL injection. It removes all the funny characters that can affect a mod rewrite.

function sef($datab)
{
    
$replacement_chars = array(",",""","","-",":","\","'"," ",".","%","@","#","!","&","/");
    $return_data = (str_replace($replacement_chars,"_",$datab));
    #print $return_data . "

";
    return($return_data);

}
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

Login

Who's Online

475 user(s) are online (351 user(s) are browsing Support Forums)


Members: 0


Guests: 475


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits