---
title: "Sökmotorvänligt hur??"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/177749-sökmotorvänligt-hur"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "ponting"
published: "2009-03-30T14:10:07.000Z"
updated: "2010-06-01T06:37:10.000Z"
replies: 4
views: 551
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/177749-sökmotorvänligt-hur"
---

# Sökmotorvänligt hur??

## #1 — ponting, 2009-03-30T14:10Z

Jag håller på en liten bookmarks: <http://lankbase.linkeater.tk>
men den är ej seo vänlig, hur gör jag om,redict.php så det blir seo vänligt??
Koden ser ut så här:
\<?php
/\* $Id: redirect.php,v 1.12 2005/10/19 07:12:35 dbu Exp $
   Task: increment the 'hit counter' of the right link and redirect the user to
         the correct URL

   LinkBase
   A web application (written in PHP) that helps to manage the Internet bookmarks
   of an organisation (such as a company, a school...) by centralizing those
   links in a single multi-user database (SQL). You can then access this base
   with a web browser.
   Copyright (C) 2003-2005  David BUCHMANN \<budda@budda.ch\>
   Copyright (C) 2001-2003  Jean HAUSSER \<jhausser@tuxfamily.org\>
   
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   \*/
error_reporting(E_ALL); //fixme: only for debugging

require_once('inc/common.inc.php');
//calls a function in common.inc.php which does initialization, sanity check and session management
$lb_error = lb_init();
if ($lb_error) {
  echo '\<html\>\<head\>\<title\>Error\</title\>\</head\>'.
    '\<body\>\<p\>Severe configuration error: '.$lb_error.
    '\</p\>\</body\>\</html\>';
  exit();
}

if ( isset($\_REQUEST\['id'\]) ) {
//this is no method, so global is not needed, but for info:
//global $lb_session, $lb_config, $lb_lang, $lb_linkdb;
    
  if (! $lb_session-\>canView($lb_linkdb-\>getOwnerOfLink($\_REQUEST\['id'\]))) {
    echo '\<html\>\<head\>\<title\>Error\</title\>\</head\>\<body\>';
    echo $lb_theme-\>error($lb_lang\['access_denied_error'\]);
    echo '\</body\>\</html\>';
    exit();
  }

  $link = $lb_linkdb-\>getLink($\_REQUEST\['id'\]);

  if ( ! $link ) {
    echo '\<html\>\<head\>\<title\>Error\</title\>\</head\>\<body\>';
    echo $lb_theme-\>error($lb_lang\['displink_error'\]);
    echo '\</h1\>\</body\>\</html\>';
    exit();
  }

  $is_down = ($link\['down_since'\] \> 0);
  
  $check_needed = ( ( time() - $link\['last_checked'\]) / (60\*60\*24) \>=
		    $lb_config\['url_check_interval'\] );
  if ($check_needed \|\| $is_down) {
    $is_down = ! $lb_linkdb-\>checkUrl($\_REQUEST\['id'\], $link\[6\], $link\[9\], true);
  }
  if (! $is_down ) {
    $lb_linkdb-\>updateLinkHits($link\['id'\]);

    if (strstr($link\['url'\], ';') === FALSE) {
        header('Location: '.  $link\['url'\]); // redirect to the website
        echo '\<html\>\<head\>\<title\>LinkBase Redirect\</title\>\</head\>\<body\>';
    } else {
        //do no automatic redirect for unicode urls. they are encoded as html, thus would have a ; in the location: header, which the browser does not like.
        echo '\<html\>\<head\>\<title\>LinkBase Redirect\</title\>';
        echo '\<meta http-equiv="REFRESH" content="0;url='.$link\['url'\]. '"\>';
        echo '\</head\>\<body\>';
        }
    echo 	'\<a href="'.$link\['url'\].'"\>'.$link\['title'\].'\</a\>'.
	'\</body\>\</html\>';
    } else { // a unsuccessful check was performed
      echo '\<html\>\<head\>\<title\>LinkBase\</title\>\</head\>\<body\>'.
	'\<a href="'.$link\['url'\].'"\>'.$link\['title'\].'\</a\> '.$lb_lang\['site_down'\].' '.
	$lb_config\['url_check_maxdowntime'\].' '.$lb_lang\['days'\].
	'\</body\>\</html\>';
    }

} else {
  header('Location: ./'); //no link specified, go to index
}

?\>
\*\*
nån som vore bussig  och kan hjälpa mig??

Permalänk: https://www.webforum.nu/p/177749

## #2 — drew, 2009-03-30T14:28Z

Det vore mycket lättare att läsa om du använt code-taggen.

Permalänk: https://www.webforum.nu/p/2177073

## #3 — Draqir, 2009-03-30T15:12Z

.. och allt som borde postats är...

```
if (strstr($link['url'], ';') === FALSE) {
header('Location: '. $link['url']); // redirect to the website
echo '<html><head><title>LinkBase Redirect</title></head><body>';
} else {
echo '<html><head><title>LinkBase Redirect</title>';
echo '<meta http-equiv="REFRESH" content="0;url='.$link['url']. '">';
echo '</head><body>';
}
echo '<a href="'.$link['url'].'">'.$link['title'].'</a>'.
'</body></html>';
} else { // a unsuccessful check was performed
echo '<html><head><title>LinkBase</title></head><body>'.
'<a href="'.$link['url'].'">'.$link['title'].'</a> '.$lb_lang['site_down'].' '.
$lb_config['url_check_maxdowntime'].' '.$lb_lang['days'].
'</body></html>';
}
```

Men det spelar ingen roll hurvida redirect funktionen är SEO vänlig eller ej med REFRESH värde noll. Problemet är att ingen av sidorna är särskilt SEO vänliga. Ett litet försök har gjorts med att skriva \<h1\> lite här och var (på gränsen till spam). Meta name/descriptions saknas, struktur saknas, m.m. Om du insisterar på att göra det själv så köp en bok om SEO, finns lite för mycket att nämna.

Permalänk: https://www.webforum.nu/p/2177085

## #4 — ponting, 2009-03-30T15:28Z

OK, då skiter jag i det och gör en: PHP LD som vanligt. Tack för hjälpen i alla fall.

Permalänk: https://www.webforum.nu/p/2177088

## #5 — newseed, 2010-06-01T06:37Z

Den enda redirect som är måttligt bättre än andra redirects (alla är dåliga ur SEO-perspektiv) är en 301 (moved permanently):

\<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/");
exit();
?\>

Detta säger alltså till sökmotorn att ALLTID du besöker denna sida är det en redirect till den andra sidan. Google har höjt 302 till att vara bättre än 301 (moved temporarily). 302 är annars den som vanligast genereras om man i script-språk ber om en redirect, 301 måste man explicit ange.

Permalänk: https://www.webforum.nu/p/2239022

---

Tråden på webben: https://www.webforum.nu/amne/php/177749-sökmotorvänligt-hur
