Như tiêu đề e đã viết. Hiện tại website của e đã rewrite hết tất cả URL. Nhưng bây giờ e muốn làm thên cái redirect none www to www để cho SEO nó nhanh lên nhưng ko hiểu sao khi e cho thêm đoạn code này vào
if (Request.Url.AbsoluteUri.ToLower().StartsWith("htt p://www.") == false)
{
Response.Status = "301 Moved Permanently";
string sNewLocation = null;
sNewLocation = Request.Url.AbsoluteUri.ToLower().Replace("http://", "http://www.");
Response.AddHeader("Location", sNewLocation);
return;
}
thì nó đã redirect được từ none www về www nhưng rewrite URL bị hỏng (tức là url nó về dạng .aspx?id=... như lúc đầu e chưa rewrite)
Cú pháp rewrite 1 url trong webconfig của e có cấu trúc như thế này
<rewrite url="^~/([\w-]+)/tour/([\w-]{1,})-([0-9]+)-([0-9]+).html$" to="~/TourDetail.aspx?Lang=$1&TourTypeID=$3&ID=$ 4"/>
Vậy tiền bối nào đã từng gặp lỗi này hay có cách fix thì giúp e với. Em xin cảm ơn !
không cần viết code phức tạp thế đâu.
http://stackoverflow.com/questions/18774992/redirecting-non-www-to-www-using-url-rewrite-2-0