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

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

0 Members and 2 Guests are viewing this topic.

jojomart

  • Guest
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #420 on: December 09, 2007, 01:42:09 AM »
I don't know what I've done wrong, if anything, but when I click on one of the pictures in my gallery, I get a 404 error instead of the right page - The url looks right, but it can't find the page:

http://www.wannaberichtoo.com/wallpaper/r-nature-1-35-below-kenai-alaska-35.htm

Here is the code for my .htaccess file:

Code: [Select]
# Begin search engine friendly links code
RewriteEngine On
RewriteBase /wallpaper/
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

I'm at a loss, please help me,

Joanne

Offline beach-baer

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #421 on: December 21, 2007, 08:30:21 PM »
Moin Moin!

Da meine Englischkenntnisse leider nahezu unbrauchbar sind, versuche ich das hier einmal auf deutsch. :roll:

Ich nutze diesen Mod schon seit Monaten ohne Probleme. Am Montag hat mein Provider ein Betriebssystemwechsel auf Debian durchgeführt und prompt gibt es Schwierigkeiten. Wenn ich die Seite zum ersten Mal, frisch im neuen Browserfenster aufrufe und dann auf die Galerieseite gehe, haben alle URLs  wieder eine Session-ID. Ich vermute, dass das Problem in der Index.php liegt. Erst nach dem zweiten Durchlauf der Index.php tauchen die Session-IDs nicht mehr auf.

Da mein Provider auch keine Lösung parat hat, baue ich auf die Kompetenz dieses Forums. Kennt einer das Problem...?

Ganz doll dankbar für eine Lösung  :D

Kay

Offline tirakle

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #422 on: January 04, 2008, 02:31:52 PM »
Hallo,

ich habe das gleiche Problem. Jedoch seit Anfang an. Wenn man die Gallery zum ersten Mal aufruft, haben alle URLs eine Session-ID. Wenn man weiterklickt, dann geht diese weg. Habe nun alles x-mal neu installiert und ausprobiert. Jedoch ohne Erfolg. Hat jemand eine Idee an was es liegen kann bzw. kann mir jemand seine htaccess + sessions.php, die 100% funktioniert zur Verfügung stellen ? Wäre noch einen Versuch wert.

Offline beach-baer

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #423 on: January 04, 2008, 02:43:32 PM »
Moin Moin!

Hier ist die Lösung: http://www.entwickler-blog.de/archiv/251-Session-ID-nicht-in-der-URL-sondern-nur-im-Cookie-speichern.html


Du brauchts dafür eine eigene separate php.ini, in der "session.use_trans_sid" auf off gestellt werden muss. Das musst Du mit deinem Provider klären. Bei hat sich das Problem damit auf jeden Fall erledigt gehabt.

Viel Glück und viele Grüße aus Hamburg

Kay

P.S. Und auch ein "Frohes Neues" an alle hier  :)
« Last Edit: January 04, 2008, 05:51:14 PM by beach-baer »

Offline ClickyMouse

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #424 on: January 30, 2008, 08:44:53 PM »
It is possible to have this Mod without the .htaccess file?

Because my Server don't allow it...

Thanks!

Offline maineyak

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #425 on: February 21, 2008, 03:12:34 PM »
I want to use Rewrite on the upload feature as well.

Therefor I have entered this into .htaccess:

Quote
RewriteRule ^catupload([0-9]+)\.html$ member.php?action=uploadform&cat_id=$1&%{QUERY_STRING}

But it doesn't work. Why not?

Thanks

For one thing, You cannot even access the upload button until you're logged in, which google can't do. Furthermore, it's no big deal about rewriting search url's either, as Google cannot search.

Offline maineyak

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #426 on: March 03, 2008, 04:55:24 AM »
I have found one problem with this, I'm hoping someone can help. When I go to lightbox and click an image, the image url is now http://www.domain.com/image222.lightbox.htm, whereas everyewhere else on my site, the image is http://www.domain.com/tattoo-designs-web-face-222.htm.

How can I get it to show correctly like the rest of my site?

Djith and me ordered this mod, to put image name and category name in url.
After testing and debugging, we think it is ok now, and we are happy to share it with you.


This mod puts the names of the categories and the images in the url like this :
for image --->http://www.your-site.com/img-imagename-andnumber.htm
category --->http://www.your-site.com/cat-categoryname-andnumber.htm

you can see it working on http://www.edupics.com (1.7) and http://www.avatarcorner.com (1.7.1)
on these sites the "img" and "cat" in the url were changed to some keywords.
( see http://www.4homepages.de/forum/index.php?topic=6729.msg41243#msg41243 )


there is also the possibility to make url's with full path to image and categories : ( see //comment in mod )
for image --->http://www.your-site.com/img-full path to image.htm
category --->http://www.your-site.com/cat-full path of category.htm
This was not tested on our sites.


Don't forget to backup your files before editing !

files to be edited :
.htaccess
includes/sessions.php

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 = "&") {
    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].'.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 ProDez

  • Pre-Newbie
  • Posts: 9
    • View Profile
    • MultiMedia Center
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #427 on: March 04, 2008, 03:00:51 PM »
Many Thanks. It works fine!
Danke, damit funktioniert meine Seite nun viel besser und
die urls lassen sich viel leichter feststellen...  :D

ProDez,
http://www.portavision.de/mediacenter/
Glauben ist nicht "Wissen". Aber, ich glaube das weiss jeder.

Offline olgaart

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • FotoClub
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #428 on: March 20, 2008, 10:57:03 AM »
Anybody knows, if it works on 1und1 hosting? Tried to install and it did not work on my homepage http://www.fotoclub.robertmagel.de/
Many Tnx

Offline Suricata

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #429 on: March 29, 2008, 09:06:54 AM »
Hallo,

ich musste den MOD wieder bei mir wieder entfernen, weil ich Fehler 404 bekomme, sobald ich die home.html verlasse.

Eine Lösung zu dem problem konnte ich leider hier nicht finden.

Viele Grüße
Suricata

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #430 on: April 01, 2008, 06:51:31 PM »
geht das auch mit der 1.7.6 ?

Offline tiamo86

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #431 on: April 16, 2008, 04:08:02 AM »
okie
I read all post of this topic but it so confution
What correct the way to hack mod for seo friendly.
I want it like:
sitename.com/categories -> and title of page like :  Categories - <title of website>
sitename.com/categories/img-name.html -> and title of page like: img-name - <title of website>

i think it better for SEO.

The gallery source can do (http://gallery.menalto.com/) but is very slow, that i use 4images.

Please help.
Thanks all

Offline knucklehead

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #432 on: April 18, 2008, 12:24:04 AM »
Does this MOD work with v1.7.6?  I already tried the Google SEO mod with no success on 1.7.6.

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #433 on: April 18, 2008, 04:44:01 AM »
Does this MOD work with v1.7.6?  I already tried the Google SEO mod with no success on 1.7.6.

yes, works pretty good (http://www.myanimalsworld.com)
« Last Edit: August 07, 2008, 03:59:10 PM by om6acw »

Offline knucklehead

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #434 on: April 19, 2008, 04:54:25 AM »
Does this MOD work with v1.7.6?  I already tried the Google SEO mod with no success on 1.7.6.

yes, works pretty good (http://www.myanimalsword.com)

Nice, thanks allot for the reply om6acw!!  I'll try installing when I get back home.  I'll post a link if I'm successful.