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

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

0 Members and 1 Guest are viewing this topic.

Offline k1lljoy

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Razruha.Ru
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #495 on: January 07, 2010, 06:29:53 PM »
Just use the code, I believe provided somewhere in this topic, that would switch off sessionid for the bots only...If I recall correctly that code is based on "treat bots as members" mod or something like that..
Sorry, I don't have time at the moment to be more specific, but it's there ;)
Thanks, Vano, but that solution works only for search-bots, and as far as I know - even they are still getting sessionids on their first visit...not to say about the simple visitors...
And I want to get rid of that sessionid completely, so theat nobody could never see it again  :D

I tried different methods, and must say now, that right now I've just undone the changes in includes/sessions.php, which i described here: http://www.4homepages.de/forum/index.php?topic=6729.msg144014#msg144014
that is - I've made it look like:
Code: [Select]
  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;
    }
And all the sessions are gone now!  8)

I really do not know, maybe this snippet of code is wrong in some way, inappropriate or something else, but right now ny site works fine and the sessionids' are gone - so it turned out to be a solution for me.
 So - if someone wants to get rid of sessionsids' completele - You should probably try it as well  :roll:



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 #496 on: January 08, 2010, 12:54:11 AM »
just remove
      $url .= strpos($url'?') !== false $amp "?";
      
$url .= SESSION_NAME."=".$this->session_id;
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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #497 on: May 18, 2010, 11:39:15 AM »
Works fine, THANKS

But, can i do next:

From:
http://my.domain/img990.htm?l=russian

To:
http://my.domain/photo/{additional fields}/image_id

Or simething like that???

Offline muhammet93

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #498 on: July 23, 2010, 06:25:16 PM »
I have a question.
For example, ý have cars category, and inside it there is a picture named renault.
I want to use www.domainname.com/cars/renault link to enter to the picture.Is that possible?

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
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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #500 on: September 19, 2010, 10:12:00 PM »
1 question.

 Ok. All work done. But how to merge together this: http://www.4homepages.de/forum/index.php?topic=6729.msg57268#msg57268 and this: http://www.4homepages.de/forum/index.php?topic=6729.msg48487#msg48487

Please can you give me ready code?

1.1 question

This is my path.  How will be see this path after merging?
 RewriteRule ^img/(.*)/([0-9]+)/ details.php?image_id=$2&%{QUERY_STRING}


Thanks!

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 #501 on: September 19, 2010, 10:19:43 PM »
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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #502 on: September 21, 2010, 06:23:18 PM »
I made this type of my links http://domain.ru/photo-uzbekistan-airways-boeing-767-3cb(28er)29-2746.htm

Before it link was: http://domain.ru/img1676.htm

Now this link is not available and get error 404. http://domain.ru/img1676.htm May i do a redirect? If, yes. How?

Many thanks

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 #503 on: September 21, 2010, 06:51:39 PM »
The simplest solution would be just leave support for the old type of URLs:
Code: [Select]
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}
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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #504 on: September 21, 2010, 07:33:03 PM »
Why do you think that? Is it not better in terms of SEO optimization? Thanks for code!

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 #505 on: September 21, 2010, 07:45:52 PM »
no, it is not better, but at least you don't get 404 errors ;) It's just the simplest way.

The more difficult way is to redirect from within details.php and it is not very optimized way either. If you still want go that way, I may try cook something for you later today.
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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #506 on: September 21, 2010, 07:52:54 PM »
Ok, will be very interesting to try and finished this. I`ll be awaiting for you. Thanks V@no!

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 #507 on: September 21, 2010, 09:43:26 PM »
ok, here it is.
in htaccess add these lines:

Code: [Select]
RewriteRule ^img([0-9]+)\.htm$ details.php?image_id=$1&old&%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.([a-zA-Z0-9]+)\.htm$ details.php?image_id=$1&mode=$2&old&%{QUERY_STRING}

In details.php find:
require(ROOT_PATH.'includes/sessions.php');

Insert below :below::
if (isset($HTTP_GET_VARS['old']))
{
  unset(
$HTTP_GET_VARS['old']);
  
$query "";
  foreach(
$HTTP_GET_VARS as $key => $val)
  {
    
$query .= "&" $key "=" $val
  }
  
$query trim($query"&");
  
header('HTTP/1.1 301 Moved Permanently');
  
redirect(ROOT_PATH "details.php" . ($query "?" $query ""));
}
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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] Search Engine Friendly URLs aka Short URLs
« Reply #508 on: September 21, 2010, 09:52:29 PM »
Special thanks this work perfectly. And last question:

In my details.html i show to users link to the photo throught this code

<a href="<?=$site_sess->url(ROOT_PATH."details.php?image_id={image_id}")?>">http://domain.ru/<?=$site_sess->url(ROOT_PATH."details.php?image_id={image_id}")?></a>

Why this path show me this type of link?

http://domain.ru/./photo-vim-airlines-ilyushin-il-62m-1676_

 Where i need to delete ./?

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 #509 on: September 21, 2010, 09:55:04 PM »
because of ROOT_PATH constant.
This should work:

Code: [Select]
<a href="<?=$site_sess->url("details.php?image_id={image_id}")?>">http://domain.ru/<?=$site_sess->url("details.php?image_id={image_id}")?></a>
but keep in mind, this type of URL will contain sessionid= if cookies are blocked or on very first visit the page, this is not recomended for links that visitors would use to share with others.
A possible work around this issue is use this instead:
Code: [Select]
<?php
$backupGet 
$site_sess->get;
$site_sess->get "cookie";
?>

<a href="<?=$site_sess->url("details.php?image_id={image_id}")?>">http://domain.ru/<?=$site_sess->url("details.php?image_id={image_id}")?></a>
<?php
$site_sess
->get $backupGet;
?>
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)