1. Trang chủ
  2. » Công Nghệ Thông Tin

htaccess và redirect 301 là gì

6 373 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

htaccess redirect 301 301 redirect htaccess 301 redirect htaccess example 301 redirect htaccess one page to another create 301 redirect htaccess code for 301 redirect htaccess htaccess redirect 301 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 302 htaccess 301 redirect htaccess 301 redirect generator htaccess 301 redirect folder wordpress 301 redirect htaccess htaccess redirect 301 + 301 redirect htaccess 301 redirect htaccess example 301 htaccess redirect create 301 redirect htaccess code for 301 redirect htaccess htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 htaccess 301 redirect htaccess 301 redirect generator htaccess 301 redirect examples nginx 301 redirect using htaccess wordpress 301 redirect htaccess htaccess redirect 301 + a apache htaccess 301 redirect 301 redirect htaccess one page to another htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess 301 redirect one domain to another htaccess 301 redirect tutorial apache htaccess redirect 301 + b htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + c create 301 redirect htaccess code for 301 redirect htaccess htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + d htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess 301 redirect domain if file doesnt exist 301 redirect htaccess htaccess redirect 301 + e 301 redirect htaccess example htaccess redirect 301 exclusion htaccess 301 redirect examples htaccess 301 redirect example if file doesnt exist 301 redirect htaccess htaccess redirect 301 + f 301 redirect htaccess file code for 301 redirect htaccess htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess 301 redirect folder htaccess file 301 redirect if file doesnt exist 301 redirect htaccess htaccess redirect 301 + g htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess 301 redirect generator htaccess redirect 301 + h htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + i htaccess redirect 301 exclusion htaccess redirect 301 to html if file doesnt exist 301 redirect htaccess htaccess redirect 301 + j htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + k htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + l htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess 301 redirect loop htaccess redirect 301 + m htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + n htaccess redirect 301 exclusion htaccess redirect 301 to html nginx 301 redirect using htaccess htaccess redirect 301 + o 301 redirect htaccess one page to another htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess 301 redirect one domain to another htaccess redirect 301 + p 301 redirect htaccess one page to another htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect page 301 htaccess 301 redirect with parameters htaccess 301 redirect 404 pages htaccess redirect 301 + q htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess redirect 301 + r htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess redirect 301 + s htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess 301 redirect syntax htaccess redirect 301 + t 301 redirect htaccess one page to another htaccess redirect 301 to html htaccess 301 redirect one domain to another htaccess 301 redirect tutorial htaccess 301 redirect tutorial apache htaccess redirect 301 + u htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess redirect 301 + v htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + w htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess 301 redirect wordpress htaccess 301 redirect with parameters htaccess 301 redirect website wordpress 301 redirect htaccess htaccess redirect 301 + x htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess redirect 301 + y htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + z htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess redirect 301 + 0 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + 1 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + 2 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + 3 htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess redirect 301 + 4 htaccess redirect 301 exclusion htaccess redirect 301 to html htaccess 301 redirect 404 pages htaccess redirect 301 + 5 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + 6 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + 7 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + 8 htaccess redirect 301 to html htaccess redirect 301 exclusion htaccess redirect 301 + 9 htaccess redirect 301 to html htaccess redirect 301 exclusion

.htaccess redirect 301 gì? htaccess tệp tin cấu hình đặc biệt, htaccess cho phép bạn thay đổi cách hoạt động máy chủ Apache tầng thư mục Tệp tin htaccess gồm dòng lệnh, tùy biến theo người dùng, đặt thư mục đó, có tác dụng cho thư mục tất thư mục Một ứng dụng phổ biến htaccess cho phép viết lại đường dẫn URL (rewrite URL) Trở lại ứng dụng SEO htaccess, khách hay bọ tìm kiếm thăm trang web, máy chủ kiểm tra tệp tin đặt biệt để tìm tùy biến webmaster, bao gồm tùy biến bảo mật Máy chủ sau thực thi lệnh tìm thấy tệp tin htaccess thường gồm chuyển hướng redirection, bảo mật báo lỗi Redirect 301 ? Chuyển hướng redirect 301 hay redirection 301 thường hiểu việc di rời vĩnh viễn (moved permanently) Nó trả mã lỗi 301 phần header nhằm thông báo cho máy tìm kiếm hay trình duyệt, máy chủ trang web chuyển rời tới địa Cài đặt redirect 301 Điều bạn phải đảm bào server Apache bạn hỗ trợ mod_rewrite cho phép sử dụng htaccess để áp dụng redirect 301 Sau bạn phải tải tệp tin htaccess từ thư mục gốc chứa trang web bạn Nếu bạn tệp tin htaccess thư mục gốc bạn phải tạo với trình soạn thảo text Notepad, Ultraedit hay EditPadPro, v.v Phải chắn bạn viết tên có dấu chấm “.” đầu tệp tin Người sử dụng Windows tạo tệp tin htaccess tệp tin đặc biệt không chứa tên, chứa tên phần tên mở rộng Vì bạn tải tệp tin text window tải lên server qua FTP đổi tên sever Sau tải tệp tin htaccess xuống máy, có dòng lệnh trước cẩn thận đừng thay đổi bạn không chắc, tốt lưu để phòng trường hợp cần thiết bạn quay trở lại Cài đặt DÒNG LỆNH BẮT ĐẦU HTACCESS Dòng lệnh htaccess bạn nên bắt đầu sau : Options +FollowSymLinks RewriteEngine On RewriteBase / DÒNG LỆNH CƠ BẢN REDIRECT 301 Dòng lệnh redirect 301 có dạng sau tệp tin htaccess : redirect 301 /old/old.htm http://www.adela.vn/new.htm Dòng lệnh thông báo chuyển rời tệp tin old.htm thư mục old đến vị trí http://www.adela.vn/new.htm Chú ý : Để bắt đầu bạn nên redirect 301 trang host, bạn nên chuyển trang cũ đến thư mục gốc tương đối Có thể thực việc việc loại bỏ “http://www.adela.vn/” mà thêm đường dẫn tương đối đến thư mục gốc Điểm mạnh nhât việc thay đổi hàng loạt đường dẫn URL mod_rewrite Apache, đặc biệt thay đổi tên miền hay thư mục hay số lượng lớn tập tin Chúng ta tìm hiểu phần Chuyển toàn đến tên miền Nếu bạn định thay đổi tên miền đường dẫn trước từ website bên ngoài, từ máy tìm kiếm đường dẫn tuyệt đối website cũ bị thay đổi bạn truy cập, địa trỏ bạn đến trang báo lỗi 404 : trang không tìm thấy Vì bạn thay đổi tên miền đừng để liên kết quí báu người dùng tiềm từ máy tìm kiếm, redirect liên kết cũ tới tên miền : Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.adela.vn/$1 [R=301,L] Hãy thay đổi www.adela.vn tên miền bạn Redirect toàn trang thư mục đến mọt trang Giả sử bạn không sử dụng thư mục “kienthucseo” muốn chuyển tất trang thư mục đến trang “trainingseo.html” thêm dòng lệnh sau vào tệp tin htaccess nằm thư mục gốc : RewriteRule ^kienthucseo(.*)$ /trainingseo.html [L,R=301] Chuyển trang động tới trang Để chuyến trang web động page.php?id=n (với n giá trị biến) tới trang tĩnh new-page.html bạn làm sau : RewriteRule ^page.php?id=(.*)$ /new-page.htm [L,R=301] URL với www hay không www Đôi bạn bắt gặp việc website sử dụng “www” URL (Ví dụ http://www.adela.vn), có website lại không dùng “www” http://tuoitre.vn/ Nên nhớ “tương ứng” với dịch vụ Web Các bạn lựa chọn riêng cho Nhưng chọn hai gây trùng lặp nội dung sau hai ví dụ, hướng dẫn bạn sủ lý triệt để vấn đề TRƯỜNG HỢP SỬ DỤNG WWW Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\.adela.\.vn$ [NC] RewriteRule ^(.*)$ http://www.adela.vn/$1 [R=301,L] Ngoài có cách viết sau áp dụng cho tất host domain, edit lại : Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC] RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$ [NC] RewriteRule ^/(.*)$ http://%1/$1 [R=301,L] TRƯỜNG HỢP KHÔNG SỬ DỤNG WWW Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^tuoitre\.vn$ [NC] RewriteRule ^(.*)$ http://tuoitre/$1 [R=301,L] Bạn thử lại với tên miền ví dụ mà áp dụng thành công trích dẫn Loại bỏ Query_String Đôi trang web bạn hiển thị hai đường dẫn url khác ( nội dung) ví dụ seo-services.html seo-services.php?v=mobile Tương tự phần trên, điều tạp nội dung trùng lặp website bạn Vì bạn loại bỏ tham biến sau : RewriteCond %{THE_REQUEST} ^GET\ /.*\;.*\ HTTP/ RewriteCond %{QUERY_STRING} !^$ RewriteRule * http://www.adela.vn%{REQUEST_URI}? [R=301,L] Ngoài tham biến QUERY_STRING không gấn giá trị hết URl kết thúc biến rỗng “?”, bạn nên loại bỏ chúng, ví dụ “index.html?” : RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} RewriteRule ^index.html /index.html? [L] Chuyển phần đuôi mở rộng từ php sang html Việc chuyển php sang html có tác dụng bạn cần viết lại đường dẫn thân thiện với máy tìm kiếm (Friendly URL for SEO) RewriteRule ^(.*)\.html$ $1.php [R=301,L] Chuyển gạch (_) thành gạch ngang(-) Dù Google chấp nhận việc sử dụng gạch “_” ký tự ngăn cách, thực tế người dùng quen thuộc với dấu gạch ngang “-” Bản thân seovietnam ủng hộ dấu gạch ngang dễ nhìn Bạn chuyển đổi toàn dấu “_” sang “-” sau : Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule !\.(html|php)$ - [S=4] RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes] RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes] RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes] RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes] RewriteCond %{ENV:uscor} ^Yes$ RewriteRule (.*) http://www.adela.vn/$1 [R=301,L] Redirect Wordpress Feeds tới Feedburner Trong viết sử dụng Feedbuner, bạn sử dụng plugin để quản lý Feeds RSS Blog Wordpress Nếu không bạn sử dụng code htaccess sau : RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/feed\.gif$ RewriteRule * - [L] RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC] RewriteRule ^feed/?.*$ http://feeds.adela.vn/dichvuseo/ [L,R=302] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /index.php [L] Đối với người dùng WordPress, bạn sử dụng plug-in Redirection Permanent Link để chuyến hướng trang Bảo vệ ăn cắp tài nguyên băng thông Đôi tài liệu, film hay hình ảnh mà bạn tải host bị người khác dùng đăng website khác gây tốn băng thông, bạn hạn chế việc ăn cắp cách cho phép tài nguyên tiếp cận website bạn cho phép sau (Nếu không trả thư mục /feed/) : RewriteEngine On RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?adela.vn/.*$ [NC] RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L] Ứng dụng redirect 301 máy chủ khác (ngoài Apache) IIS redirect Trong phần quản trị dịch vụ internet, nhấn phải chuột chọn tệp tin thư mục mà bạn muốn áp dụng redirect; Chon nút “a redirection to a URL”; Chọn trang Redirection; Chon tiếp “The exact url entered above” “A permanent redirection for this resource”; Chon “Apply” ColdFusion Redirect PHP Redirect Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.adela.vn" ); ?> ASP Redirec ASP net Redirect JSP (Java) Redirect CGI PERL Redirect $q = new CGI; print $q->redirect("http://www.adela.vn/"); Ruby on Rails Redirect def old_action headers["Status"] = "301 Moved Permanently" redirect_to "http://www.sadela.vn/" end ...DÒNG LỆNH CƠ BẢN REDIRECT 301 Dòng lệnh redirect 301 có dạng sau tệp tin htaccess : redirect 301 /old/old.htm http://www.adela.vn/new.htm Dòng lệnh thông... [R=302,L] Ứng dụng redirect 301 máy chủ khác (ngoài Apache) IIS redirect Trong phần quản trị dịch vụ internet, nhấn phải chuột chọn tệp tin thư mục mà bạn muốn áp dụng redirect; Chon nút “a redirection... a URL”; Chọn trang Redirection; Chon tiếp “The exact url entered above” “A permanent redirection for this resource”; Chon “Apply” ColdFusion Redirect

Ngày đăng: 29/11/2015, 21:54

TỪ KHÓA LIÊN QUAN

w