This question has been answered by fourroses666. See the first response.
// Personally I don't do 301 directs but let a search plugin on 404 suggest new address to the visitorhttp://forums.modx.com/thread/88953/friendly-urls-using-302-redirect-rather-than-301
or just set up the old address as a weblink.
Google rank new pages super-fast and if the _content_ of the old page is changing so will the rankings too in a short time.
&pg=Error Page;
$e = & $modx->Event; switch ($e->name) { case "OnPageNotFound": if(!$pg) $modx->sendErrorPage(); else{ //Parse out the requested page. $errorword = str_replace("/", " ", $_SERVER['REQUEST_URI']); if ($errorword != '') { //Find the .html $errorwordSuffix = ".html"; //Remove the .html if(stristr($errorword,$errorwordSuffix)) { $errorword = str_replace($errorwordSuffix, " ", $errorword); } } //Redirect to the new page with a 301 header $modx->sendRedirect('http://www.YOURSITE.com/'.$errorword, 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); exit; } break; default : return; // stop here break; }
<link rel="canonical" href="http://url/page">
<link rel="canonical" href="[[if? &is=`[*id*]:is:1` &then=`[(site_url)]` &else=`[(site_url)][~[*id*]~]`]]" />
Options +FollowSymLinks -MultiViews DirectorySlash Off RewriteCond %{SCRIPT_FILENAME}/ -d RewriteCond %{SCRIPT_FILENAME}.html !-f RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L] RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^(.+)\.html$ /$1 [R=301,L] RewriteCond %{SCRIPT_FILENAME}.html -f RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
Redirect /Test http://www.mydomain.nl/contact
Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC] RewriteRule .* - [F,L] RewriteRule ^(manager|assets) - [L] # For Friendly URLs RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] Redirect /Test http://www.mydomain.nl/contact
RewriteRule ^Test$ http://www.mydomain.nl/contact [L,R=301]
RewriteCond %{REQUEST_URI} /Test$ RewriteRule (.*) /contact [S,L,R=301]
Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule ^Test$ http://www.mydomain.nl/contact [L,R=301] #OR #RewriteCond %{REQUEST_URI} /Test$ #RewriteRule (.*) /contact [S,L,R=301] RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC] RewriteRule .* - [F,L] RewriteRule ^(manager|assets) - [L] # For Friendly URLs RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteRule ^Test$ http://www.mydomain.nl/contact [L,R=301