Mod rewrite 生成页面url jquery
我想从索引页重定向到另一个传递id的页面。 在html中,我有以下代码 我正在使用jquery,我有这个代码Mod rewrite 生成页面url jquery,mod-rewrite,url-rewriting,url-routing,url-parameters,Mod Rewrite,Url Rewriting,Url Routing,Url Parameters,我想从索引页重定向到另一个传递id的页面。 在html中,我有以下代码 我正在使用jquery,我有这个代码 $("<a class='theme-btn default-btn' href='#'>Read more </a></button>").appendTo($target).click(function() { document.location.href='post.html?id=' + $id;
$("<a class='theme-btn default-btn' href='#'>Read more </a></button>").appendTo($target).click(function() {
document.location.href='post.html?id=' + $id;
});
$(“”)。附加到($target)。单击(函数(){
document.location.href='post.html?id='+$id;
});
重定向后,url为>
我想像这样>
我怎样才能做到这一点?我知道你想做什么。 您必须在服务器端使用重写URL来完成此操作 根据您的服务器设置,这将位于web.config(适用于IIS)或htaccess(Apache)中 下面是一个IIS重写规则的示例,与您的问题相关
<rule name="Category Rule">
<match url="post/([0-9]+)-([0-9]+)*.aspx" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="post.aspx?id={R:1}" appendQueryString="true" />
</rule>
如果URL是/post.aspx?id=14
这将返回URL/post/14
为了使其正常工作,您的页面需要某种逻辑来确定显示了哪些内容,具体取决于页面的ID。例如,要获取页面内容的数据库的哪一行。您能提供一个示例吗?在html中我有