View Single Post
Tuổi 20-04-2012, 02:21 PM   #1
hoctinhoc
Guest
 
Trả Lời: n/a
Cách chuyển hướng website từ www qua non-www
Cách chuyển hướng website từ www qua non-www


Thí dụ:


Nếu bạn muốn khi khách hàng truy cập vào http://www.quantrinet.com thì sẽ chuyển qua trang http://quantrinet.com

thì bạn làm như sau:

1. Trên máy chủ Web Server là: apache

- Enable mod_rewrite trên Server

- Tạo và đặt file .htaccess với nội dung bên dưới vào thư mục / của website

Mã:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.quantrinet.com [NC]
RewriteRule ^(.*)$ http://quantrinet.com/$1 [L,R=301]


2. Trên máy chủ Web Server là: IIS
6

Có 2 cách để bạn làm việc này

Cách 1:

Sử dụng ISAPI Rewrite (đây là mod_rewrite trên IIS bạn phải cài đặt vào)

Cách 2:

Vào IIS tạo 2 website: 1 website là www.quantrinet.com và 1 website là: quantrinet.com

Trên website: www.quantrinet.com bạn vào phần Property --> Home Directory --> chọn vào các thành phần sau:

A redirection to a URL
Redirect to: http://quantrinet.com
The exact URL enterd above
A permanent redirectiong for this resource



3. Trên máy chủ IIS 7


- Tạo 1 website tên với header là: www.quantrinet.com
- Trong phần Physical Path (trỏ đến thư mục bất kỳ, không tro vào thư mục của website: quantrinet.com - do cấu hình site này sẽ lưu trong file web.conf)
- Chọn HTTP Redirect trên website: www.quantrinet.com và nhập vào: http://quantrinet.com và chọn "status code" là: 301 (permanent)


If you want a virtual directory or a site in IIS7.x to redirect to another url you first have to make sure you have installed http redirect for IIS.
To do that goto Control Panel > Program and Features and select Turn Windows features on or off


Choose IIS and click on Add Role Services and make sure you check HTTP Redirection


Let the feature be installed and configured.

Now you will see the HTTP Redirect option in the Features View of IIS.

Click HTTP Redirect and add the necessary redirect information to add a redirect for a virtual directory or an entire site.


http://serverfault.com/questions/880...in-without-www

Chúc các bạn thành công!

  Trả lời ngay kèm theo trích dẫn này