Sunday, January 17, 2010

redirect 301

The "301 Permanent Redirect" adalah yang paling efisien dan ramah mesin pencari metode untuk mengarahkan website. You can use it in several situations, including: Anda dapat menggunakannya dalam beberapa situasi, termasuk:

* to redirect an old website to a new address untuk mengarahkan situs lama ke alamat baru
* to setup several domains pointing to one website untuk men-setup beberapa domain yang menunjuk ke satu situs web
* to enforce only one version of your website (www. or no-www) menegakkan hanya satu versi dari situs Web Anda (www. atau tanpa www)
* to harmonize a URL structure change untuk menyelaraskan perubahan struktur URL

There are several ways to setup a 301 Redirect, below I will cover the most used ones: Ada beberapa cara untuk men-setup ulang 301 Redirect, di bawah ini saya akan menutupi yang paling banyak digunakan:

PHP Single Page Redirect PHP Single Page Redirect

In order to redirect a static page to a new address simply enter the code below inside the index.php file. Dalam rangka untuk mengarahkan ulang halaman statis ke alamat baru masukkan kode di bawah ini di dalam file index.php.



PHP Canonical Redirect Canonical PHP Redirect

The Canonical 301 Redirect will add (or remove) the www. Redirect 301 Canonical akan menambahkan (atau menghapus) www. prefixes to all the pages inside your domain. awalan untuk semua halaman dalam domain Anda. The code below redirects the visitors of the http://domain.com version to http://www.domain.com. Kode di bawah arahan ulang para pengunjung dari versi ke http://www.domain.com http://domain.com.



Apache .htaccess Singe Page Redirect Apache. Htaccess menghanguskan Page Redirect

In order to use this method you will need to create a file named .htaccess (not supported by Windows-based hosting) and place it on the root directory of your website, then just add the code below to the file. Untuk menggunakan metode ini anda perlu membuat sebuah file bernama. Htaccess (tidak didukung oleh hosting berbasis Windows) dan meletakkannya di direktori root website anda, maka tambahkan saja kode di bawah ini ke file.

Redirect 301 /old/oldpage.htm /new/http://www.domain.com/newpage.htm

Apache .htaccess Canonical Redirect Apache. Htaccess Canonical Redirect

Follow the same steps as before but insert the code below instead (it will redirect all the visitors accessing http://domain.com to http://www.domain.com) Ikuti langkah yang sama seperti sebelumnya, tetapi memasukkan kode di bawah ini bukan (itu akan mengarahkan ulang semua pengunjung mengakses http://domain.com untuk http://www.domain.com)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

ASP Single Page Redirect ASP Single Page Redirect

This redirect method is used with the Active Server Pages platform. Metode redirect ini digunakan dengan Active Server Pages platform.

<% Response.Status="301 Moved Permanently" Response.AddHeader='Location','http://www.new-url.com/' %>

ASP Canonical Redirect Canonical ASP Redirect

The Canonical Redirect with ASP must be located in a script that is executed in every page on the server before the page content starts. Canonical Redirect dengan ASP harus berada dalam sebuah skrip yang dilaksanakan di setiap halaman pada server sebelum dimulai konten halaman.

<% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME") End if %>

No comments:

Post a Comment