Knowledgebase:SEO Hacks
Contents
Neuer Domain Name den Suchmaschinen melden
Dies sollte immer mit einer 301 Status Meldung erfolgen. <HIGHLIGHTSYNTAX><?php header("Status: 301 Moved Permanently"); header("Location: http://www.YOUR-NEW-DOMAINNAME.com"); exit; ?></HIGHLIGHTSYNTAX>
Weiterleitungen bei bestimmten Domainnamen
Dies kann erreicht werden, in dem in die index.php Datei (im Kopfteil) ein Redirect Script eingebunden wird. Beispiel wie folgt:
Datei: index.php <HIGHLIGHTSYNTAX> require_once dirname(__FILE__).'/customizing/redirect.php'; </HIGHLIGHTSYNTAX>
Datei: customizing/redirect.php
<HIGHLIGHTSYNTAX>
<?php
/**
- Weiterleitungsscript
- COMVATION AG Switzerland
- www.contrexx.com
- redirect.php // als Includedatei
- /
$redirectDomain = "yourdomain.com"; $redirectDomain2 = "yourdomain2.com";
if (empty($_SERVER['argv'])) { if (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.') { $host = strtolower(substr($_SERVER['HTTP_HOST'], 4)); } else { $host = strtolower($_SERVER['HTTP_HOST']); } if($host == "$redirectDomain" || $host == "$redirectDomain2") { $newLocation = "index.php?page=100"; // Example header('Location: '.$newLocation); exit; } } ?> </HIGHLIGHTSYNTAX>
Globale Seitentitel bei bestimmten Domainnamen
Sie möchten den globalen Seitentitel (z.B. <title>[[GLOBAL_TITLE]]</title> ) bei bestimmten Domain Aliasen anpassen. Dies kann erreicht werden, in dem die index.php Datei wie folgt angepasst wird:
Datei: index.php <HIGHLIGHTSYNTAX> //------------------------------------------------------- // set global template variables //-------------------------------------------------------
if (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.') { $host = strtolower(substr($_SERVER['HTTP_HOST'], 4)); } else { $host = strtolower($_SERVER['HTTP_HOST']); }
switch ($host){ case "YOURDOMAIN.COM": $globalTitle = "Contrexx ist ein cooles CMS"; break; case "YOURDOMAINXYZ.COM": $globalTitle = "Contrexx ist verdammt cool!"; break; default: $globalTitle = $_CONFIG['coreGlobalPageTitle']; break; } </HIGHLIGHTSYNTAX>
Damit es einwandfrei funktioniert, müssen Sie noch $_CONFIG['coreGlobalPageTitle'] mit $globalTitle ersetzten, das finden sie unter: "set global template variables".
URL Optimierungen
Quelle: HTML5 Boilerplate
- Suppress or force the "www." at the beginning of URLs
# The same content should never be available under two different URLs - especially not with and # without "www." at the beginning, since this can cause SEO problems (duplicate content). # That's why you should choose one of the alternatives and redirect the other one. # By default option 1 (no "www.") is activated. Remember: Shorter URLs are sexier. # no-www.org/faq.php?q=class_b # If you rather want to use option 2, just comment out all option 1 lines # and uncomment option 2. # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME! # ---------------------------------------------------------------------- # Option 1: # Rewrite "www.domain.com -> domain.com" <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] </IfModule> # ---------------------------------------------------------------------- # Option 2: # To rewrite "domain.com -> www.domain.com" uncomment the following lines. # Be aware that the following rule might not be a good idea if you # use "real" subdomains for certain parts of your website. # <IfModule mod_rewrite.c> # RewriteCond %{HTTPS} !=on # RewriteCond %{HTTP_HOST} !^www\..+$ [NC] # RewriteCond %{HTTP_HOST} (.+)$ [NC] # RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L] # </IfModule>
- Add/remove trailing slash to (non-file) URLs
# Google treats URLs with and without trailing slashes separately. # Forcing a trailing slash is usually preferred, but all that's really # important is that one correctly redirects to the other. # By default option 1 (force trailing slash) is activated. # http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html # http://www.alistapart.com/articles/slashforward/ # http://httpd.apache.org/docs/2.0/misc/rewriteguide.html#url Trailing Slash Problem # ---------------------------------------------------------------------- # Option 1: # Rewrite "domain.com/foo -> domain.com/foo/" # <IfModule mod_rewrite.c> # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ # RewriteRule ^(.*)$ /$1/ [R=301,L] # </IfModule> # ---------------------------------------------------------------------- # Option 2: # Rewrite "domain.com/foo/ -> domain.com/foo" #<IfModule mod_rewrite.c> # RewriteRule ^(.*)/$ /$1 [R=301,L] #</IfModule>