如果URL中的任何字符均为大写,我编写了以下规则以重定向到小写URL
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . https://www.example.com${lc:%{REQUEST_URI}} [R=301,L]
以上规则可以将https://www.example.com/HelloWorld重定向到https://www.example.com/helloworld
以上规则非常有效,但后来我想推迟所有与实际文件URL对应的URL的小写形式。例如,我想将上述规则推迟用于
https://www.example.com/ABC.png(如果服务器上实际存在ABC.png文件)。
为此,我在下面添加了行RewriteCond %{REQUEST_FILENAME} !-f
RewriteMap lc int:tolower
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . https://www.example.com${lc:%{REQUEST_URI}} [R=301,L]
尽管进行了上述更改,https://www.example.com/ABC.png已重定向到ttps://www.example.com/abc.png。这应该很简单,但是不起作用。
答案 0 :(得分:0)
解决了。在虚拟主机的上下文中使用protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = (DataRowView)e.Row.DataItem;
for (int i = 0; i < drv.DataView.Table.Columns.Count; i++)
{
if (drv.DataView.Table.Columns[i].ColumnName.StartsWith("GT_"))
{
e.Row.Cells[i].BackColor = System.Drawing.Color.LawnGreen;
grdAdd.Columns[i].HeaderStyle.BackColor = System.Drawing.Color.Khaki;
}
}
}
}
时,应将其写为RewriteCond %{REQUEST_FILENAME} !-f
。因此,在这种情况下,总体规则将是
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f