步步为营-90-SEO(url重写+超链接技巧)
2024-08-21 16:21:28
目的:便于搜索引擎抓取
url重写:将带参数的url如:https://i.cnblogs.com/EditPosts.aspx?opt=1.修改为https://i.cnblogs.com/EditPosts.aspx_1
1:在BookList修改如下链接方式
href="<%#Eval("Id","/Goods/BookDetail_{0}.aspx") %>">
2:添加Global文件
在Application_BeginRequest方法进行url地址的重写
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string url = Request.AppRelativeCurrentExecutionFilePath;//~/Goods/BookDetail_4939.aspx
Match match=Regex.Match(url, @"~/Goods/BookDetail_(\d+).aspx");
if (match.Success)
{
Context.RewritePath("/Goods/BookDetail.aspx?id="+match.Groups[1].Value);
}
}
超链接技巧:由于SEO执行js脚本
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SeoTest.aspx.cs" Inherits="BookShop.Web.Test.SeoTest" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="../js/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(function () {
$("#a1").click(function () {
$.post("/ashx/seo.ashx", {}, function (data) {
$("#div1").append(data);
});
return false;
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="Javascript:void(0)" id="a1">mmm</a>
<div id="div1"></div> </div>
</form>
</body>
</html>
原来的代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SeoTest.aspx.cs" Inherits="BookShop.Web.Test.SeoTest" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="../js/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(function () {
$("#a1").click(function () {
$.post("/ashx/seo.ashx", {}, function (data) {
$("#div1").append(data);
});
return false;
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="/ashx/seo.ashx" id="a1">mmm</a>
<div id="div1"></div> </div>
</form>
</body>
</html>
修改后
仅仅修改了: <a href="/ashx/seo.ashx" id="a1">mmm</a>
最新文章
- Vs2015智能提示英文?
- JavaBean组件的基本使用-语法
- 从C# 到 OC
- input覆盖select实现select可写可选择
- [转]ORACLE的ProC用法讲解
- MyBatis参数传入集合之foreach动态sql
- File的getParentFile()和getParent()
- 【Android 应用开发】BluetoothSocket详解
- java中的i++与++i的区别以及除法、模的用法(基础)
- 在IT行业获得成功 你只需一项技能[转]
- 4-20模块 序列化模块 hashlib模块
- Ajax 执行顺序
- SQL Server 临时表和表变量系列之选择篇
- [转]Kindle 推送教程:教你用电子邮箱推送电子书
- [洛谷 P3787] 冰精冻西瓜
- 嵌入式ROOTFS transplantation
- npm与gulp的使用
- js数组遍历 千万不要使用for...in...
- 写给在Java和.net中徘徊的新手
- ibatis 调用存储过程
热门文章
- mybatis-plus调用自身的 selectById 方法报错:org.apache.ibatis.binding.BindingException:
- CF1108F MST Unification
- 从无文件技术到使用隐写术:检查Powload的演变
- eMMC基础技术3:eMMC总线token
- opencv处理验证码python代码
- SPOJ - DQUERY D-query 主席树
- HDU 4455
- JS 手机端多张图片上传
- 使用SimHash进行海量文本去重[转]
- Confluence 6 配置默认语言界面