{ Snipperize } /redirect

Snippets about redirect

Here are the latest snippets talking about redirect. Please choose your favorite one or add a new one.

Code Snippets To Implement 301 Redirect

Sometimes, if you use a CMS like WordPress or Movable Type, you could need to change the URL structure in use on your blog with a more SEO friendly structure. This is a big problem especially if your site is already indexed and some posts are popular on search engines: if you change the URL structure, all your posts will be unavailable at the old URLs and, in this way, you risk to lose visitors and ranking. A safe way to change the URL structure of your blog, without losing visitors and ranking, is to apply a permanent redirect to your pages (301 redirect). This redirect says to the search engine bot “the current page has permanently moved to a new URL” so that the bot can follow the new link and properly index it. In this post I’m going to illustrate how to apply a permanent redirect to your pages using some techniques and scripting languages. Redirect 301 with htaccess In my opinion htaccess is the best and quickly way to redirect your pages. Only an advice: you need to have a base knowledge of htaccess for use it or you risk to have some serious problems on your site! So, before start using htaccess, I suggest you some good reading: Complete guide to htaccess for Beginners and Htaccess tutorials on apache.org. Here is an example of htaccess usage: Redirect permanent http://mysite.com http://www.mysite.com Now supposed you have the following two URLs: http://www.mysite.com and http://mysite.com. For Google, for example, these URLs are two different pages and their page rank will be divided among two pages. So, why not using htaccess to redirect all traffic to only one page? The only thing you have to do is to create a new file called .htaccess with the following code: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^mysite\.com [NC] RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301] </IfModule> …and put this file in the root directory (for mac users: remember that files that start with “.” are hidden, so you need to modify visualization options on your Mac or FTP clients to see them). In this way you are creating a redirect from all HTTP requests from the URL http//mysite.com to http://www.mysite.com. As I said before, htacces is the best SEO technique to redirect pages but it’s not the only one. You can also use a scripting server language to implement a permanent redirect. Here is a small list with short code snippets to implement quickly a permanent redirect using PHP, ASP, ASP.net and Coldfusion.

Plain / redirect, 301 / by ThePeppersStudio (15 days, 10.02 hours ago)

Redirect Domain Including Subdomains and Arguments

I used this as an include on every page to redirect every page incl arguments from .com to .de

PHP / redirect, subdomain, domain / by ThePeppersStudio (19 days, 6.22 hours ago)

Force Add WWW Or No WWW

You should really be doing one or the other. For consistency, as well as SEO’s, sake.

Apache / seo, htaccess, www, redirect / by ThePeppersStudio (135 days, 8.31 hours ago)

301 Redirects

This is the cleanest way to redirect a URL. Quick, easy, and search-engine friendly.

Apache / 301, redirect, htaccess / by ThePeppersStudio (135 days, 8.36 hours ago)

Correct Redirect To Location

PHP / url, redirect, link / by ThePeppersStudio (215 days, 8.77 hours ago)

Redirect 404 Error Page to Any Page

Just insert it into your .htaccess file to redirect all your 404 error pages to any address

Apache / redirect, ErrorDocument, 404 / by ThePeppersStudio (246 days, 18.44 hours ago)

  • 1