简体   繁体   English

IIS 7.0-URL重写根文件夹

[英]IIS 7.0 - URL Rewriting Root Folder

I have done a bunch of sites using URL Rewrite actions in the web.config with much success. 我已经在web.config使用URL重写操作完成了很多站点,并取得了很多成功。

Today I am trying to do the following rewrite rule: 今天,我正在尝试执行以下重写规则:

Example url: domainname.com/ANYTHINGHERE/PRODUCTID 网址示例:domainname.com/ANYTHINGHERE/PRODUCTID

I basically want to take the product ID and pass it to a page (ie product.aspx?id=PRODUCTID 我基本上想获取产品ID并将其传递给页面(即product.aspx?id = PRODUCTID

<rule name="Rewrite Product Details Page" stopProcessing="true">
     <match url="^([^/]+)/([^/]+)$" />
     <action type="Rewrite" url="/product-view.aspx?id={R:1}" appendQueryString="true" logRewrittenUrl="true" />                    
</rule>

I've done this in the past just fine but it had to have a static root folder, for instance: domanname.com/products/ANYTHINGHERE/ID 我过去做的还不错,但是它必须有一个静态的根文件夹,例如:domanname.com/products/ANYTHINGHERE/ID

EDIT: (forgot to describe my issue), 编辑:(忘记描述我的问题),

When I try to load my page - domain.com/categoryname/PRODUCTID 当我尝试加载我的页面时-domain.com/categoryname/PRODUCTID

The product page is called by the ID is not passed in. 产品页面所调用的ID未传递。

Any ideas? 有任何想法吗? I searched and could not find anything. 我搜索了,找不到任何东西。

-Joe -乔

I think the index is not zero-based. 我认为该索引不是基于零的。 Try 尝试

<rule name="Rewrite Product Details Page" stopProcessing="true">
    <match url="^([^/]+)/([^/]+)$" />
    <action type="Rewrite" url="/product-view.aspx?id={R:2}" appendQueryString="true" logRewrittenUrl="true" />                    
</rule>

Here is a good tutorial: Creating Rewrite Rules for the URL Rewrite Module 这是一个很好的教程: 为URL重写模块创建重写规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM