• [Mod] Search Engine Friendly URLs aka Short URLs 3 0 5 1
Currently:  

Author Topic: [Mod] Search Engine Friendly URLs aka Short URLs  (Read 756652 times)

0 Members and 2 Guests are viewing this topic.

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #510 on: September 21, 2010, 10:02:20 PM »
Very nice. Now my link of details page seen more beauty and comfort for my users! Thanks you very much V@no. In future i want to apply a "/" to the links. I can do it. But then the photo will not be visible. Because it will apply to the wrong address. How to fix it I do not know

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #511 on: September 21, 2010, 11:02:19 PM »
can't answer that without knowing what exactly changes you do.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline relu

  • Newbie
  • *
  • Posts: 44
    • View Profile
    • Pulsarmedia
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #512 on: November 01, 2010, 10:45:56 PM »
hi, i searched about the way to add for thumbnail in html width= and height= this is missing from my html code. Somebody know where i must looking for?

Offline jeyjoo

  • Newbie
  • *
  • Posts: 46
  • Jeyjoo Web Design
    • View Profile
    • Sheffield Web Design
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #513 on: March 27, 2011, 05:20:26 PM »
I am running version Version: 1.7.6
my gallery is http://www.jeyjoo.com/gallery/index.php

I have tried different mods on this thread, and each time broke my gallery and had to restore original settings.
I am trying to  give each URL as a simple http://mygallery.com/gallery/details.php?image_id=239, ie. remove all the url endings such as &mode=search.

Is there a way to do this?
Much appreciated
Jeyjoo - kick ass web design, SEO and online marketing packages.

http://www.jeyjoo.com/gallery/ - free stock images (a 4images gallery)  |
http://www.jeyjoo.com - Sheffield web design  |  http://www.jeyjoo.com - Sheffield SEO  |  http://it.jeyjoo.com - Web Design Milano  |  http://it.jeyjoo.com - SEO Italiano

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #514 on: March 27, 2011, 05:40:16 PM »
Are you trying cripple functionality of your gallery? these "mode=" endings are not for decoration, you know...;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline jeyjoo

  • Newbie
  • *
  • Posts: 46
  • Jeyjoo Web Design
    • View Profile
    • Sheffield Web Design
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #515 on: July 27, 2011, 12:27:54 PM »
Seriously is there any way I can provide static URLS.
I am on 1.7.6, and cannot get this to work.

Ideally am looking to have a url of the sort: http://www.jeyjoo.com/gallery/{image_id}_{image_name}

Any ideas?

Thanks,
Mike
« Last Edit: August 08, 2011, 11:04:20 AM by jeyjoo »
Jeyjoo - kick ass web design, SEO and online marketing packages.

http://www.jeyjoo.com/gallery/ - free stock images (a 4images gallery)  |
http://www.jeyjoo.com - Sheffield web design  |  http://www.jeyjoo.com - Sheffield SEO  |  http://it.jeyjoo.com - Web Design Milano  |  http://it.jeyjoo.com - SEO Italiano

Offline swarzy

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #516 on: September 23, 2011, 05:18:38 AM »
hello, I've replaced the files you put in the first part of the post (. htaccess and sessions.php) and I get the following:

http://www.swarzycustom.com/r-galletas-dvd-2-g-13-giallo-4660.htm

I want you to stay well

http://www.swarzycustom.com/giallo.htm

What I have to change?

thanks ...

Offline rashidkhalil

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #517 on: November 28, 2011, 02:58:34 PM »
hello dear sir

Google / Sitemap Problem now ...

movies.fm95pakistan.com it my website but

google site map error

please resolve in this issues

thanks

Offline marcinos

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #518 on: January 12, 2012, 06:48:10 PM »
to address how to make html pages to look was in this form

www.sitename/search.php?q=keywords

Offline Naveen

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #519 on: June 26, 2012, 06:45:25 PM »
Ok, I have been using this mod for quite a few years now and I have had no issues untill today.

Somehow google had crawled pages with search extension i.e

Normal image url = http://www.domain.com/img123.htm
Issue URL = http://www.domain.com/img123.search.htm

This has resulted in 100s of duplicate url in google webmaster sitemaps.

http://www.domain.com/img123.search.htm  for odd reasons returns next and previous images as http://www.domain.com/img122.search.htm  and next images as http://www.domain.com/img124.search.htm

How do I get rid of this now?  :oops:

Offline sathishIPL

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #520 on: June 27, 2012, 11:43:24 AM »
Hi,

Please click the below link to solve the duplicate

http://www.4homepages.de/forum/index.php?topic=17598.0;msg=158361

Best Regards,
satz

Offline Naveen

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #521 on: June 28, 2012, 09:21:18 AM »
I already have canonical tag working on each page. However that is not the solution to the problem, I need to get rid of (*.search.htm) Infact anything.htm works and loads the page. i.e

http://www.domain.com/img123.(anythinghere).htm  <--- this should not happen.

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #522 on: March 23, 2014, 02:19:02 AM »
Hello.

How can I change this:
for image --->http://www.your-site.com/img-imagename-andnumber.htm
category --->http://www.your-site.com/cat-categoryname-andnumber.htm

To this?
for image --->http://www.your-site.com/imagename.htm
category --->http://www.your-site.com/categoryname.htm


Here's "my" MOD:

Code: [Select]
 
=================================================
1. at the end of .htaccess, add following code :
=================================================
#Mod_bmollet : category 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 ^img([0-9]+).search.htm details.php?image_id=$1&%{QUERY_STRING}

=======================================================================

=========================================
2. add this code to include/sessions.php
=========================================
//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. In include/sessions.php replace function url(...) by following code.
========================================================================
/* 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;
  }
========================================================================


========================================================================
4. In include/sessions.php following functions are useful for URL's like
   yoursite.com/maincategory/subcategory/imagename.htm
   
   This is not necessairy if you want url's (like we used on our sites) like this :
   for image --->http://www.your-site.com/img-imagename-andnumber.htm
   category --->http://www.your-site.com/cat-categoryname-andnumber.htm
========================================================================
//Mod_bmollet
/**
 * Get the category id
 * @param array $path An array with the path of the category
 * @param int $parent_id The parent id of the first item in the $path
 */
function get_category_id($path,$parent_id = 0)
{
$cat_name = array_shift($path);
global $site_db;
$sql = "SELECT cat_id FROM ".CATEGORIES_TABLE." WHERE cat_parent_id = $parent_id AND cat_name = '".mysql_real_escape_string($cat_name)."'";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
if( count($path) != 0)
{
return get_category_id($path,$row['cat_id']);
}
else
{
return $row['cat_id'];
}
}
//Mod_bmollet
/**
 * Get the image id
 * @param array $path An array with the path of the image
 */
function get_image_id($path)
{
global $site_db;
$image_name = array_pop($path);
$cat_id = get_category_id($path);
$sql = "SELECT image_id FROM ".IMAGES_TABLE." WHERE image_name = '".mysql_real_escape_string($image_name)."' AND cat_id = $cat_id";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
return $row['image_id'];
}
========================================================================


Offline nameless

  • Full Member
  • ***
  • Posts: 147
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #523 on: June 06, 2018, 10:46:44 AM »
Dear
I want to know
are there any disadvantages for this mod
because i see it's a simple than Google Friendly Urls For 4images Best Seo Mod

thanks