Well, I just have done optimize SEO for one of my website using 4images gallery system it’s on http://www.innovativedesktop.com basically I play with meta title, keywords, and description. And now I’m using URL rewrite. URL look cool and more search engine friendly I believe after a week or month it will indexed in lot of search engine 😀

Here is the way for you’re to using URL rewrite on 4images to make it more search engine friendly REMEMBER this will eat CPU resources. (before you doing this I recommended to backup your files first). Any alternative you can learn about URL rewrite yourself to make it works as you want (google is the best teacher).

1. You need to make .htaccess file and put this code on it

RewriteEngine On
RewriteRule ^lightbox\.html$ lightbox.php?%{QUERY_STRING}
RewriteRule ^lightbox\.([0-9]+)\.html$ lightbox.php?page=$1&%{QUERY_STRING}
RewriteRule ^search\.html$ search.php?%{QUERY_STRING}
RewriteRule ^search\.([0-9]+)\.html$ search.php?page=$1&%{QUERY_STRING}
RewriteRule ^postcard([a-zA-Z0-9]+)\.html$ postcards.php?postcard_id=$1&%{QUERY_STRING}
RewriteRule ^postcard\.img([0-9]+)\.html$ postcards.php?image_id=$1&%{QUERY_STRING}
RewriteRule ^k_(.*)_([0-9]+).html categories.php?cat_id=$2&%{QUERY_STRING}
RewriteRule ^r_(.*)_([0-9]+).html details.php?image_id=$2&%{QUERY_STRING}
RewriteRule ^r([0-9]+).search.html details.php?image_id=$1&%{QUERY_STRING}

2. Open /include/sessions.php before the last line add this code

//Mod_bmollet
/**
* Get the category url
* @param int $cat_id The id of the category
* @param string $cat_url The current status of the URL
*/
function get_category_url($cat_id,$cat_url = ”)
{
global $site_db;
$sql = “SELECT cat_name,cat_parent_id FROM “.CATEGORIES_TABLE.” WHERE cat_id = ‘”.$cat_id.”‘”;
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$row[‘cat_name’] = strtr($row[‘cat_name’], “ÃÃÃÃÃÃÃÃÃÃABCDEFGHIJKLMNOPQRSTUVWXYZ”,”eeeaeauoiaabcdefghijklmnopqrstuvwxyz”);
$cat_url = ‘_’.str_replace(‘+’,’_’,urlencode($row[‘cat_name’])).’_’.$cat_id.$cat_url;
// if you want full path of category in url, put next line in comment
return $cat_url;
if( $row[‘cat_parent_id’] != 0)
{
return get_category_url($row[‘cat_parent_id’],$cat_url);
}
else
{
return $cat_url;
}
}
//Mod_bmollet
/**
* Get the image url
* @param int $image_id The id of the image
*/
function get_image_url($image_id)
{
global $site_db;
$sql = “SELECT cat_id,image_name FROM “.IMAGES_TABLE.” WHERE image_id = ‘”.$image_id.”‘”;
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$row[‘image_name’] = strtr($row[‘image_name’], “ÃÃÃÃÃÃÃÃÃÃABCDEFGHIJKLMNOPQRSTUVWXYZ”,”eeeaeauoiaabcdefghijklmnopqrstuvwxyz”);
// if you want comlpete path to image in url, remove comment from following line
//return get_category_url($row[‘cat_id’]).’-‘.str_replace(‘+’,’-‘,urlencode($row[‘image_name’])).’-‘.$image_id;
return ‘_’.str_replace(‘+’,’_’,urlencode($row[‘image_name’])).’_’.$image_id;
}

3. Find this code on /include/sessions.php

function url($url, $amp = “&”) {
global $l;
$dummy_array = explode(“#”, $url);
$url = $dummy_array[0];

if ($this->mode == “get” && !preg_match(“/”.SESSION_NAME.”=/i”, $url)) {
$url .= preg_match(“/\?/”, $url) ? “$amp” : “?”;
$url .= SESSION_NAME.”=”.$this->session_id;
}

if (!empty($l)) {
$url .= preg_match(“/\?/”, $url) ? “$amp” : “?”;
$url .= “l=”.$l;
}

$url .= (isset($dummy_array[1])) ? “#”.$dummy_array[1] : “”;
return $url;
}

Replace it with this code

/* ORIGINAL CODE
function url($url, $amp = “&”) {
global $l;
$dummy_array = explode(“#”, $url);
$url = $dummy_array[0];

if ($this->mode == “get” && !preg_match(“/”.SESSION_NAME.”=/i”, $url)) {
$url .= preg_match(“/\?/”, $url) ? “$amp” : “?”;
$url .= SESSION_NAME.”=”.$this->session_id;
}

if (!empty($l)) {
$url .= preg_match(“/\?/”, $url) ? “$amp” : “?”;
$url .= “l=”.$l;
}

$url .= (isset($dummy_array[1])) ? “#”.$dummy_array[1] : “”;
return $url;
}
*/
function url($url, $amp = “&”) {
global $l, $user_info;
$dummy_array = explode(“#”, $url);
$url = $dummy_array[0];
$url = str_replace(‘&’, ‘&’, $url);
if (!defined(‘IN_CP’)) {
if (strstr($url, ‘index.php’)) {
$url = str_replace(‘index.php’, ”, $url);
}
elseif (strstr($url, ‘search.php’)) {
if (strstr($url, ‘page=’)) {
preg_match(‘#page=([0-9]+)&?#’, $url, $matches);
if (isset($matches[1])) {
$split = explode(‘?’, $url);
$url = $split[0];
$query = @$split[1];
$url = str_replace(‘search.php’, ‘search.’.$matches[1].’.html’, $url);
$query = str_replace(‘page=’.$matches[1].’&’, ”, $query);
$query = str_replace(‘&page=’.$matches[1], ”, $query);
$query = str_replace(‘page=’.$matches[1], ”, $query);
if (!empty($query)) {
$url .= ‘?’ . $query;
}
}
}
else {
$url = str_replace(‘search.php’, ‘search.html’, $url);
}
}
elseif (strstr($url, ‘lightbox.php’)) {
if (strstr($url, ‘page=’)) {
preg_match(‘#page=([0-9]+)&?#’, $url, $matches);
if (isset($matches[1])) {
$split = explode(‘?’, $url);
$url = $split[0];
$query = @$split[1];
$url = str_replace(‘lightbox.php’, ‘lightbox.’.$matches[1].’.html’, $url);
$query = str_replace(‘page=’.$matches[1].’&’, ”, $query);
$query = str_replace(‘&page=’.$matches[1], ”, $query);
$query = str_replace(‘page=’.$matches[1], ”, $query);
if (!empty($query)) {
$url .= ‘?’ . $query;
}
}
}
else {
$url = str_replace(‘lightbox.php’, ‘lightbox.html’, $url);
}
}
elseif (strstr($url, ‘categories.php’)) {
if (strstr($url, ‘cat_id=’) && strstr($url, ‘page=’)) {
preg_match(‘#cat_id=([0-9]+)&?#’, $url, $matches1);
preg_match(‘#page=([0-9]+)&?#’, $url, $matches2);
if (isset($matches1[1]) && isset($matches2[1])) {
$split = explode(‘?’, $url);
$url = $split[0];
$query = @$split[1];
$url = str_replace(‘categories.php’, ‘cat’.$matches1[1].’.’.$matches2[1].’.html’, $url);
$query = str_replace(‘cat_id=’.$matches1[1].’&’, ”, $query);
$query = str_replace(‘&cat_id=’.$matches1[1], ”, $query);
$query = str_replace(‘cat_id=’.$matches1[1], ”, $query);
$query = str_replace(‘page=’.$matches2[1].’&’, ”, $query);
$query = str_replace(‘&page=’.$matches2[1], ”, $query);
$query = str_replace(‘page=’.$matches2[1], ”, $query);
if (!empty($query)) {
$url .= ‘?’ . $query;
}
}
}
elseif (strstr($url, ‘cat_id=’)) {
preg_match(‘#cat_id=([0-9]+)&?#’, $url, $matches);
if (isset($matches[1])) {
$split = explode(‘?’, $url);
$url = $split[0];
$query = @$split[1];
$cat_url = get_category_url($matches[1]);
$url = str_replace(‘categories.php’, ‘cat’.$cat_url.’.html’, $url);
$query = str_replace(‘cat_id=’.$matches[1].’&’, ”, $query);
$query = str_replace(‘&cat_id=’.$matches[1], ”, $query);
$query = str_replace(‘cat_id=’.$matches[1], ”, $query);
if (!empty($query)) {
$url .= ‘?’ . $query;
}
}
}
else {
$url = str_replace(‘categories.php’, ‘cat.html’, $url);
}
}
elseif (strstr($url, ‘details.php?image_id=’)) {
if (strstr($url, ‘image_id=’) && strstr($url, ‘mode=’)) {
preg_match(‘#image_id=([0-9]+)&?#’, $url, $matches1);
preg_match(‘#mode=([a-zA-Z0-9]+)&?#’, $url, $matches2);
if (isset($matches1[1]) && isset($matches2[1])) {
$split = explode(‘?’, $url);
$url = $split[0];
$query = @$split[1];
$url = str_replace(‘details.php’, ‘img’.$matches1[1].’.’.$matches2[1].’.html’, $url);
$query = str_replace(‘image_id=’.$matches1[1].’&’, ”, $query);
$query = str_replace(‘&image_id=’.$matches1[1], ”, $query);
$query = str_replace(‘image_id=’.$matches1[1], ”, $query);
$query = str_replace(‘mode=’.$matches2[1].’&’, ”, $query);
$query = str_replace(‘&mode=’.$matches2[1], ”, $query);
$query = str_replace(‘mode=’.$matches2[1], ”, $query);
if (!empty($query)) {
$url .= ‘?’ . $query;
}
}
}
else {
preg_match(‘#image_id=([0-9]+)&?#’, $url, $matches);
if (isset($matches[1])) {
$split = explode(‘?’, $url);
$url = $split[0];
$query = @$split[1];
$url = str_replace(‘details.php’, ‘img’.get_image_url($matches[1]).’.html’, $url);
$query = str_replace(‘image_id=’.$matches[1].’&’, ”, $query);
$query = str_replace(‘&image_id=’.$matches[1], ”, $query);
$query = str_replace(‘image_id=’.$matches[1], ”, $query);
if (!empty($query)) {
$url .= ‘?’ . $query;
}
}
}
}
elseif (strstr($url, ‘postcards.php?image_id=’)) {
preg_match(‘#image_id=([0-9]+)&?#’, $url, $matches);
if (isset($matches[1])) {
$split = explode(‘?’, $url);
$url = $split[0];
$query = @$split[1];
$url = str_replace(‘postcards.php’, ‘postcard.img’.$matches[1].’.html’, $url);
$query = str_replace(‘image_id=’.$matches[1].’&’, ”, $query);
$query = str_replace(‘&image_id=’.$matches[1], ”, $query);
$query = str_replace(‘image_id=’.$matches[1], ”, $query);
if (!empty($query)) {
$url .= ‘?’ . $query;
}
}
}
}
if ($this->mode == “get” && strstr($url, $this->session_id)) {
$url .= strpos($url, ‘?’) !== false ? ‘&’ : ‘?’;
$url .= SESSION_NAME.”=”.$this->session_id;
}
if (!empty($l)) {
$url .= strpos($url, ‘?’) ? ‘&’ : ‘?’;
$url .= “l=”.$l;
}
$url = str_replace(‘&’, $amp, $url);
$url .= isset($dummy_array[1]) ? “#”.$dummy_array[1] : “”;
return $url;
}

Not sure on what are you doing?! just download this package file and put it on your hosting server! seo.rar

And.. you’re done! congratulation 😀 You can modify the code to make it works like you want. Anyway if you need to make script more stronger for SEO you might need to coding auto sitemap each time there is new images added. I try but no luck (not sure if xml works fine and accepted by most search engine because it’s works on IE but not showing correctly on firefox) maybe next time I will write it.

Similar Posts:

Related Search Terms:

    Digg Del.icio.us StumbleUpon Reddit Twitter RSS

If you're new here, you may want to subscribe to my RSS feed. You may copy or publish this article to your blog or other site as long you give credit link back to this site article. Thanks for visiting my blog!