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 POST :
- PHP:Catching keyword from search engine
- PHP: How To Create Copyright Watermark On Your Images
- SEO: Search engine friendly link, Using URL Rewrite on .htaccess
- How To Stop WP-CRON.php From Using To Much CPU Usage
Incoming search terms:
- 4images seo friendly url
- 4images sef urls
- lightbox url rewriting folder
- preg match url rewriting
- preg_match for seo url
- preg_match get url rewrite
- seo for 4images
- $row[cat_name] = strtr($row[cat_name] 4images
- seo friendly url 4images
- seo friendly url mod for 4images 1 7 10
- seo optimierung 4images
- seo optimization id in url rewrite
- seo url rewrite
- slimbox2 not working after url rewrite
- youtube lightbox mod rewrite
- lightbox url rewrite
- lightbox image friendly url
- 4images 1 7 10 search friendly urls
- 4images 1 7 10 seo
- 4images delete lightbox
- 4images disable lightbox
- 4images meta
- 4images removing seo
- 4images sef long url
- 4images seo for 1 7 10
- 4images seo freundliche url
- 4шьфпуы ыущ гкд
- howto htaccess preg replace for seo
- lightbox and url rewriting
- zina seo htaccess
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!






Did you know?
Tag cloud
Blogs Statistic
Subscribe my feed

April 20th, 2008 at 9:14 AM
Istanto, big thanks for this tips I try it and it works in my website I will back soon to read your another article
April 24th, 2008 at 2:43 PM
nice article, i was looking this way long time ago.. how you can implement this script into phpmotion script?
May 3rd, 2008 at 4:12 AM
nice tips , I’ll give it a try
May 13th, 2008 at 8:47 PM
Verry much thanks…code is working…For now is ok
June 12th, 2008 at 4:10 AM
thanks
July 15th, 2008 at 5:35 AM
Thanks, awesome mod I just installed it on my site. No hicups and no issues at all.
Mark
July 21st, 2008 at 5:40 AM
NP just waiting until google indexed your page it will bring lot of visitor daily
August 13th, 2008 at 7:44 AM
Using 4images 1.7.6 and I recieve the following error after appling the mod:
Parse error: syntax error, unexpected ‘&’, expecting ‘)’ in /home/karaya/public_html/includes/sessions.php on line 401
This is the line 401 – function url($url, $amp = “&”) {
Any ideas?
Thanks!
Ray
August 14th, 2008 at 4:04 AM
Hi karaya the problem is on your editor, open your file with notepad and change “ with ” hope it will fix your problem
August 14th, 2008 at 3:01 PM
Do you mean change my sessions.php using notepad? I’m using UltraEdit. Perhaps if I use the DOS mode text editing feature?
Thanks for all your help!
Ray
August 14th, 2008 at 3:16 PM
Yes, I’m sure problem in editor(I’m usually use notepad, always when change everything) or maybe because my fault make this code not run on your site, when I type character ” in article it changed into this character “ so this will make php false to execute.
August 14th, 2008 at 4:25 PM
You can download it from here http://www.istanto.net/moveweb/4imagesSEO.rar this include .htaccess and sessions.php before upload it backup your first.
August 17th, 2008 at 8:48 AM
Hello and thankyou. Had it working okay until I discovered my New Images page would 404 when you clicked the thumbnail. I switched back to the default sessions.php until I can figure out why my New Images page will not work properly. Any ideas or suggestions?
Thanks!
Ray
August 17th, 2008 at 1:09 PM
Hello Ray, This code only working for 4images version 1.7.4 you might want to look for your version at http://www.4homepages.de/forum/index.php?board=11.0
October 5th, 2008 at 8:00 AM
After having loads of hassle trying to work out google friendly URLS I was so lucky to find your page, I am using 1.7.6 and used your downloadable pages, uploaded them and hey! it worked 1st time, I just wanted to post a big thank you!
Martin
October 6th, 2008 at 10:42 AM
Have fun Martin
October 10th, 2008 at 4:31 PM
Hello peoples!
If somebody knows, tell me! I trying to find a text about Great Britan Can somebody help me ti find it? Thanks!
December 31st, 2008 at 6:58 AM
hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch
May 15th, 2009 at 2:46 AM
thx
May 19th, 2009 at 8:48 AM
Hello,
Thanks for your great job!
I have made necessary modifications as you mentioned,my problem is, any image page is displayed as a static .htm page but categories are always displayed as .php?cat_id=22.
For your information my site is hosted in multiple domain host package,is this why categories are displayed as intented ?
what else i need to make category.php? to be dispayed as .htm page
Any Help would be appreciated
Regards,
zorex
May 20th, 2009 at 12:48 AM
what 4images version? try googling about .htaccess rewritebase
July 8th, 2009 at 12:49 AM
This is great job my friend. Thank you so much.
July 28th, 2009 at 4:39 AM
Thanks for sharing good work
July 31st, 2009 at 9:35 PM
I converted the .htaccess code into lighttpd rewrite rules (not done yet, just a small change it will working), if someone need this code just talk to me
September 27th, 2009 at 9:10 AM
Wow, nice gb. Thnx…
September 28th, 2009 at 3:03 PM
Very wonderful guestbook. Thnx…
October 9th, 2009 at 3:12 PM
Very Interestingly portal. Thnx…
December 21st, 2009 at 7:59 PM
now see the current url is
http://www.istanto.net/maximize-your-website-potential-earnings.html
can you please explain that how can we change this url to this
http://www.innovativedesktop.com/k-anime-1-amaenaideyo-214.html ??
i just want to add “-” b;w urls instead of “_”
December 21st, 2009 at 8:00 PM
***correction.
now see the current url is
http://www.innovativedesktop.com/k_anime_1_amaenaideyo_214.html
can you please explain that how can we change this url to this
http://www.innovativedesktop.com/k-anime-1-amaenaideyo-214.html ??
i just want to add “-” b;w urls instead of “_”
December 23rd, 2009 at 11:44 AM
Read in your .htaccess find RewriteRule ^k_(.*)_([0-9]+).html categories.php?cat_id=$2&%{QUERY_STRING} Change that code to RewriteRule ^k-(.*)-([0-9]+).html categories.php?cat_id=$2&%{QUERY_STRING}
January 26th, 2010 at 9:50 AM
How you do this?? http://www.innovativedesktop.com/k_anime_1_amaenaideyo_214.html and also show categories name instead of example cat12.htm??? The functions get_category_url AND get_image_url are not used in this MOD. Where to call this functions?
January 26th, 2010 at 4:38 PM
That a little modification on template header files.
January 27th, 2010 at 7:51 AM
Can you explain this further? What needs to be changed?
January 27th, 2010 at 8:09 PM
Just add this code into your theme header files {image_description} it will extract your image description to target the better search result on search engine.
February 25th, 2010 at 8:24 AM
i need rewrite sitemap url how i can do it
April 21st, 2010 at 5:25 AM
hello, does this trick works on any version?
i’m using 4images 1.7.7, i applied your chages, but no result… it’s just like in the beginning
April 22nd, 2010 at 6:15 PM
it’s work for 4images version 1.7.4 not sure about new version some people reports it works some didn’t works. I think it can be used on new version but you have to understand the structure first, I will write for new version when I’m free.
June 21st, 2010 at 7:41 AM
This is actually a pretty informative site, and I don’t say that for just any I randomly browse. Congrats, you’ve got a regular reader! I heart internet marketing! Cheers! =)
June 28th, 2010 at 10:15 PM
Ok this was pretty fun to read but I got lost about 1/2-way through. Suppose I shouldn’t drunkenly google but ah well.
June 29th, 2010 at 4:27 AM
My cousin recommended this blog and she was totally right keep up the fantastic work!
July 13th, 2010 at 8:55 PM
Ok this was pretty fun to read
August 17th, 2010 at 4:53 AM
This is great job my friend. Thank you so much.
September 21st, 2010 at 9:34 AM
Very good its work fine with me its helpfull thx alot
October 19th, 2010 at 3:39 AM
Excellent tips. Implemented to one of my client’s site successfully. But now the problem is with duplicate content.
Example – 1) http://jokesprank.com/gallery/r18.search.html
2) http://jokesprank.com/gallery/r_funny_dog_pictures_5_funny_dog_picture_-_surprised_pug_18.html
Both are pointing to same ditto content. Any idea how to remove them? I want to noindex the first one. I could not find out a way to write something in robots.txt or add a meta robot on that page. Any idea?
January 3rd, 2011 at 10:22 AM
It is extremely helpful for me.Amazing post and
everyone has submit their mature views regarding this,I very interested in the article,people pay more attention to high quality life style.
High quality means ,comfortable and healthy,Thanks for sharing the info.Regards,
April 11th, 2011 at 6:09 PM
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. You may copy or publish this article to your blog or other site as long you give credit link back to this site article. No hicups and no issues at all.php before upload it backup your first. I switched back to the default sessions.php until I can figure out why my New Images page will not work properly.htm page but categories are always displayed as . But now the problem is with duplicate content. I could not find out a way to write something in robots.txt or add a meta robot on that page.This is my google
April 14th, 2011 at 2:16 PM
THANKS!!! I need to
April 15th, 2011 at 4:56 AM
I will, last week ago I working on sitemap generator on manga247.com, the real files is sitemap.php but I change it via .htaccess to become sitemap.xml, it’s fully automatic updated when there is new content, I will share the tutorials maybe in next days.
April 19th, 2011 at 12:15 AM
Nice, thx!
May 21st, 2011 at 1:08 AM
Youre so cool! I dont suppose Ive read something like this before. So good to find somebody with some authentic thoughts on this subject. realy thank you for beginning this up. this web site is something that is wanted on the net, someone with just a little originality. useful job for bringing one thing new to the web!
September 20th, 2011 at 5:34 AM
i use this code for my htaccess
# Begin search engine friendly links code
RewriteEngine On
RewriteBase /
RewriteRule ^lightbox\.htm$ lightbox.php?%{QUERY_STRING}
RewriteRule ^lightbox\.([0-9]+)\.htm$ lightbox.php?page=$1&%{QUERY_STRING}
RewriteRule ^search\.htm$ search.php?%{QUERY_STRING}
RewriteRule ^search\.([0-9]+)\.htm$ search.php?page=$1&%{QUERY_STRING}
RewriteRule ^cat\.htm$ categories.php?%{QUERY_STRING}
RewriteRule ^cat([0-9]+)\.([0-9]+)\.htm$ categories.php?cat_id=$1&page=$2&%{QUERY_STRING}
RewriteRule ^cat([0-9]+)\.htm$ categories.php?cat_id=$1&%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.htm$ details.php?image_id=$1&%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.([a-zA-Z0-9]+)\.htm$ details.php?image_id=$1&mode=$2&%{QUERY_STRING}
RewriteRule ^postcard([a-zA-Z0-9]+)\.htm$ postcards.php?postcard_id=$1&%{QUERY_STRING}
RewriteRule ^postcard\.img([0-9]+)\.htm$ postcards.php?image_id=$1&%{QUERY_STRING}
# End search engine friendly links code
and only change 1 part of my sessions.php
not 2 part like this tutorials
because when i change the two part it’s get error
September 21st, 2011 at 7:23 AM
hello, my name is Aaron Medina and living in the Canary Islands (Spain). I write because I need your help, I would write to my mail. Greetings and in advance. Thank you.
October 25th, 2011 at 5:57 AM
Hello,
You can maybe even the whole update for version 1.7.10? I have completed the changes and I can not log in anymore. Error: The user does not exist.
For help, I would be very grateful.
Best regards
Bernd
October 25th, 2011 at 6:28 AM
I will help you, be specific on your question, I’m not understand what do you mean… this code only support for 4images old version.
October 25th, 2011 at 9:04 AM
Hello
I installed the version 1.7.10 on 4images http://www.kostenlose-gb.com and have changed the changes as listed in the blog. Now I can no longer log into the admin area.
I hope this is understandable, I work with google translate sorry …
October 26th, 2011 at 11:46 AM
Try to get Version 1.7.4 this code working on v 1.7.4 without any error. You can modify this code to working on v 1.7.10 but you have to understand the structure of the script first then change everything needed.