• [MOD] Google Friendly Urls For 4images Best Seo Mod 4 0 5 1
Currently:  

Author Topic: [MOD] Google Friendly Urls For 4images Best Seo Mod  (Read 708047 times)

0 Members and 1 Guest are viewing this topic.

Offline kowalski

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #60 on: September 01, 2007, 08:05:17 AM »
The one thing stopping me from using 4images on my live site is the problem with the URL


After spending several weeks fine tuning and adding lots of great mods to my site on a localhost WAMP test area I just can't get the URLs the way I want them


I've been thru the 27 pages of this MOD:

[Mod] Search Engine Friendly URLs aka Short URLs
http://www.4homepages.de/forum/index.php?topic=6729.0

and whilst I quite like the effect
eg.
www.mysite.com/cat-12 
www.mysite.com/images-321

I can't get my dropdown menu to function with that particular mod
(and also it's not great for Google SEO as it has no category or image name in the URL)




I've also tried the mod on this current thread - [MOD] Google Friendly Urls For 4images Best Seo Mod - but can't manipulate the URL the way I want because I am struggling with REGEX and the .htaccess, and my own understanding of php coding

I appreciate that you have to have the cat ID and image ID in every URL using this mod but can I split up the long URL with a forward slash? (And remove the .htm extension)

eg. I want:
www.mysite.com/categoryname-12/imagename-43

I've also managed to remove the .htm / .html / .php ending successfully but would like to split up the category and the image with a forward slash (/)

because I have sub-categories, the URL currently looks ridiculous and would help if I could have forward slashes like this - category / subcat / image


any suggestions/advice?

Offline cpuswe

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #61 on: September 12, 2007, 11:32:34 PM »
Hi!

Is there a way to replace certain characters in the image name or cat? I have / (slash) in my image names (and some cats) and that does not work. Image name is "AMD AMD-K6 3D/250 ES" url becomes http://www.site.org/img-amd-amd-k6-3d%2F250-es-323.htm and the webserver interpret it "The requested URL /img-amd-amd-k6-3d/250-es-323.htm was not found on this server." Remove %2F it all works fine.

If i could replace / with _ that would solve the problem. Doable?

Edit: As always... Give it some time. Solved!

Found and changed:
$row['image_name'] = strtr($row['image_name'], "/éèêàëâúóíáABCDEFGHIJKLMNOPQRSTUVWXYZ","_eeeaeauoiaabcdefghijklmnopqrstuvwxyz");



« Last Edit: September 13, 2007, 12:04:00 AM by cpuswe »

Offline aminhd

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • HostWQ Free Hosting
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #62 on: September 18, 2007, 02:15:31 AM »
I got loads of errors when I used the premodified files. But it worked when I edit everything manually!!!  :D Thanks a lot bro!

~ Free Hosting - 300MB Disk - 10GB Bandwidth - 4images Friendly ~

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #63 on: September 18, 2007, 03:19:36 AM »
Change:

Quote
$row['image_name'] = strtr($row['image_name']

for:

Code: [Select]
$row['image_name'] = strtr(format_text(trim($row['image_name']), 2)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline joxxxe

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #64 on: September 19, 2007, 08:34:49 AM »
it could have the name of the section, file at my title like this page

http://www.enchulatupagina.com/comentarios-en-espanol/saludos/q-hubo-40688.html

thanx

Offline cpuswe

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #65 on: September 19, 2007, 08:47:24 PM »
on search / new images - is there any way to display the actual url rather than the img15434.search.htm is display img-jamie-cook---9-15426.htm

any chance of this

James

+1, would this be possible to solve?

/Thomas

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #66 on: September 19, 2007, 08:51:29 PM »
No. If .htaccess modify for all folder in 4images ... this is no possible. Is what .htaccess do ... is re-write ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline cpuswe

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #67 on: September 19, 2007, 08:58:04 PM »
But has this to do with .htaccess? Is´nt this "problem" in the code that generates the search result?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #68 on: September 19, 2007, 09:09:59 PM »
Is what change .php to .html ... is .htaccess file (parse for server). ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline saud

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Pakistani.Pk
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #69 on: October 12, 2007, 01:38:43 PM »

Offline egyptsons

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Egypt Sons
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #70 on: October 12, 2007, 10:37:25 PM »
worked good with me  :wink:
Thanx God

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #71 on: October 19, 2007, 05:17:19 PM »
when i installed the code, everything seems to be right. all links look good. but when i click on it, the url switches again to the old. where is the problem? i doubt, i could let it be like that, because of producing double content, right?

my htaccess:

Code: [Select]
<IfModule mod_rewrite.c>
RewriteEngine On


RewriteBase /4images/


#Mod_bmollet : Cat name in URL
RewriteRule ^cat-(.*)-([0-9]+).htm categories.php?cat_id=$2&%{QUERY_STRING}

#Mod_bmollet : Image name in URL
RewriteRule ^img-(.*)-([0-9]+).htm details.php?image_id=$2&%{QUERY_STRING}

#Mod_bmollet : This is to make search function work  ( redirect links from search results )
RewriteRule ^search\.htm$ search.php?%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.search.htm$ details.php?image_id=$1&%{QUERY_STRING}

RewriteRule ^lightbox\.htm$ lightbox.php?%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.lightbox.htm$ details.php?image_id=$1&%{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}


</IfModule>

/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/

Offline sharangan

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • levikay
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #72 on: October 22, 2007, 05:00:28 PM »
hey the link to post card is not working
how will i be able to fix that?

Offline prive

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #73 on: October 22, 2007, 06:56:57 PM »
Let me add the letter ñ and Ñ
ñ &#241;
Ñ &#209;

I have done this but does not work:

Quote
//Mod_bmollet bitissss
/**
 * 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);

   $trans = array(","=>"","\\"=>"",";"=>"",":"=>"","/"=>"","&#304;"=>"i","&#305;"=>"i","&#241;"=>"ñ","&#209;"=>"Ñ","&#351;"=>"s","&#287;"=>"g","&#246;"=>"ö","Ö"=>"O","&#252;"=>"u","&#220;"=>"U","&#231;"=>"c","&#199;"=>"C","?"=>"");
   $row['cat_name']=strtr($row['cat_name'],$trans);

   $row['cat_name'] = strtr($row['cat_name'], "éèêàëâúóíáABCDEFGHIJKLMNÑOPQRSTUVWXYZsSiIÝIÇçöÖGgüÜýþÞðÐ","eeeaeauoiaabcdefghijklmnñopqrstuvwxyzssiiiiccoogguuissgg");
   $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);

   $trans = array(","=>"","\\"=>"",";"=>"",":"=>"","/"=>"","&#304;"=>"i","&#305;"=>"i","&#241;"=>"ñ","&#209;"=>"Ñ","&#351;"=>"s","&#287;"=>"g","&#246;"=>"ö","Ö"=>"O","&#252;"=>"u","&#220;"=>"U","&#231;"=>"c","&#199;"=>"C","?"=>"");

   $row['image_name']=strtr($row['image_name'],$trans);


      $row['image_name'] = strtr($row['image_name'], "éèêàëâúóíáABCDEFGHIJKLMNÑOPQRSTUVWXYZsSiIÝIÇçöÖGgüÜýþÞðÐ","eeeaeauoiaabcdefghijklmnñopqrstuvwxyzssiiiiccoogguuissgg");
   // 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;
}


Offline KPeBiz

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #74 on: October 22, 2007, 09:24:35 PM »

Thank you for this mod. This works real well!

Thank you.

1)open the .htaccess file and add the lines to the .htaccess
Code: [Select]
RewriteEngine On

#RewriteBase /
RewriteRule ^cat-(.*)-([0-9]+).htm categories.php?cat_id=$2&%{QUERY_STRING}
#Mod_bmollet : Image name in URL
RewriteRule ^img-(.*)-([0-9]+).htm details.php?image_id=$2&%{QUERY_STRING}

#Mod_bmollet : This is to make search function work  ( redirect links from search results )
RewriteRule ^search\.htm$ search.php?%{QUERY_STRING}
RewriteRule ^search\.([0-9]+)\.htm$ search.php?page=$1&%{QUERY_STRING}

2.) open /include/sessions.php before the last line ?> add the following code
Code: [Select]
//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.)open /include/sessions.php find this code

Code: [Select]
function url($url, $amp = "&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;
  }

4.)Replace with this one

Code: [Select]
/* ORIGINAL CODE
  function url($url, $amp = "&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 = "&amp;") {
    global $l, $user_info;
    $dummy_array = explode("#", $url);
    $url = $dummy_array[0];
    $url = str_replace('&amp;', '&', $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].'.htm', $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.htm', $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].'.htm', $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.htm', $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].'.htm', $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.'.htm', $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.htm', $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].'.htm', $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]).'.htm', $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].'.htm', $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;
  }

then it would like this
http://www.turkiye-resimleri.com/

also i have upload the pre-edited files for 1.7.4 http://rapidshare.com/files/33076491/seo.rar.html
this seo.rar file contains .htaccess file and /include/sessions.php file you can use it withour modifying