Rewrite URL
Rewrite URL (đôi khi gọi là short URL, URL rewriting, hay fancy URL) là một kỹ thuật cho phép ghi lại địa chỉ website (URL) từ dạng này thành một dạng khác (URL rewriting). Rewrite URL được sử dụng để tạo ra một địa chỉ web ngắn hơn và dễ nhìn hơn đối với trang web. Kỹ thuật này được biết đến như một trong những thủ thuật nhằm tối ưu hóa địa chỉ cho các cỗ máy tìm kiếm (SEO URL).
Ví dụ
URL sau có chứa chuỗi truy vấn liên quan đến module, hàm và thứ tự bài viết:
http://www.example.com/Blogs/modules.php?name=News&op=viewst&sid=696
Nó có thể được viết như sau để người xem dễ hiểu hơn:
http://www.example.com/Blogs/News/viewst/696.html
Địa chỉ thứ 2 có thể cho phép người truy cập thay đổi giữa các cấp thư mục để xem các bài viết ở cấp cao hơn. Ví dụ URL sau cho phép người truy cập xem tất cả các bài viết:
http://www.example.com/Blogs/News/
Một cách viết khác cho trường hợp:
http://example.com/wiki/index.php?title=Page_title
thành:
http://example.com/Page_title
Tác dụng
- Làm URL của trang web trở nên thân thiện và giúp tối ưu hóa công cụ tìm kiếm .
- Ngăn chặn "liên kết nội tuyến" không mong muốn.
- Không để lộ (thông qua URL) hoạt động bên trong của một trang web trước người truy cập.
- Các URL của các trang trên các trang web có thể được giữ ổn định ngay cả khi công nghệ nền tảng được sử dụng để phục vụ chúng thay đổi.
Nhược điểm
Trong một số trường hợp, viết rewrite không khoa học có thể gây ra lỗi khi người sử dụng sửa đổi một URL để truy cập ở cấp cao hơn của website. Xem ví dụ dưới đây:
- Nếu sửa link
- http://www.example.com/Blogs/News/viewst/696.html
- thành
- http://www.example.com/Blogs/News/viewst/
- sẽ gây lỗi.
- Nếu sửa link
Việc tạo ra link ảo và thêm các thành phần phục vụ mục đích SEO có thể gây ra những rắc rối không lường trước.[1]
Kỹ thuật này phải được áp dụng liên tục và lâu dài trên một website và chỉ nên thực hiện trên một site mới. Việc thay đổi có thể khiến website rớt hạng trên các công cụ tìm kiếm (tác dụng ngược của SEO).
Nền tảng web
Nhiều nền tảng web có hỗ trợ URL rewriting, bao gồm hỗ trợ trực tiếp hoặc sử dụng các module mở rộng.
- Apache HTTP Server có hỗ trợ URL rewriting bằng
mod_rewritemodule - URL Rewrite có thể sử dụng như thành phần mở rộng cho Microsoft IIS[2]
- Ruby on Rails có sẵn URL rewriting qua Routes[3]
- Java Server Faces có URL rewriting thông qua PrettyFaces: URL rewriting extension for JSF
- Django sử dụng nền tảng hệ thống regular-expressions[4]
- Java Stripes Framework đã có chức năng này, được tích hợp từ phiên bản 1.5[5]
- Có nhiều nền tảng sử dụng Perl đã có tính năng này[cần dẫn nguồn]
Xem thêm
- Permalink
- Apache HTTP Server
- Internet Information Server
- Zeus Web Server
- Content negotiation
- HTTP
- .htaccess
Chú thích
- ^ Thông báo về URL giả mạo bài viết trên Dân trí
- ^ Microsoft Web Platform
- ^ "Routes". Bản gốc lưu trữ ngày 9 tháng 5 năm 2008. Truy cập ngày 22 tháng 10 năm 2009.
- ^ Django URLconf
- ^ clean urls in Stripes 1.5
Liên kết ngoài
Apache
- mod_rewrite Apache module described as "the Swiss Army knife of URL manipulation".
- Apache Rewrite Guide This document supplements the mod_rewrite reference documentation. It describes how one can use Apache's mod_rewrite to solve typical URL-based problems with which webmasters are commonly confronted.
- mod_alias Simpler Apache module allow for manipulation and control of URLs as requests arrive at the server.
IIS (Microsoft Internet Information Services)
- How to redirect URLs to different Web sites Microsoft Knowledgebase article on built-in URL rewriting
- Scott Guthrie of Microsoft describes various techniques for URL rewriting in.NET Lưu trữ ngày 2 tháng 11 năm 2009 tại Wayback Machine
- URL Rewrite Module for IIS 7.0 from Microsoft
- URL Rewriter and Reverse Proxy Lưu trữ ngày 23 tháng 12 năm 2017 tại Wayback Machine for use on IIS 6.0 and 7.0 from Managed Fusion
Zeus Web Server
- Converting Apache rules to ZWS Lưu trữ ngày 28 tháng 8 năm 2008 tại Wayback Machine
- Redirecting clients to Alternate Pages Lưu trữ ngày 10 tháng 10 năm 2009 tại Wayback Machine
- Zeus Web Server User Guide Lưu trữ ngày 6 tháng 3 năm 2009 tại Wayback Machine see page 140 "Configuring Request Rewrite Scripts" (PDF 3.58MB)
Java Platform, Enterprise Edition (Java EE)
- HttpRedirectFilter (open source)
- UrlRewriteFilter (open source – BSD)
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.