iis seo 友好 url - 入站规则 - 可选参数?
我使用 IIS 6 中的 URL 重写功能在我的网站上创建了 SEO 友好的 URL。问题是,我编写了一个页面来处理整个子页面。我需要 URL 具有可选参数。
例如,mysite.com/offers/bikes/weekly/32/red
将转换为 mysite.com/offers/bikes.aspx?period=weekly&weeknum=32&color=red。 我希望一些参数是可选的。例如,我可以将
mysite.com/offers/bikes/weekly mysite.com/offers/bikes.aspx?period=weekly
我会在我的脚本中只设置每周,所以只显示所有周。
这将允许我按周数设置各种优惠。我必须指出,这完全是捏造的。这只是一个例子,看看是否可能?
希望这是可能的,因为目前如果我省略任何参数,它会说找不到页面。
感谢您的任何帮助。
I've used the URL rewrite feature in IIS 6 to create a SEO friendly URL on my site. The problem is, I've written a single page to handle a whole host of sub pages. I need the URL to have optional parameters.
For example, mysite.com/offers/bikes/weekly/32/red
would translate to mysite.com/offers/bikes.aspx?period=weekly&weeknum=32&color=red.
I'd like some parameters to be optional. For example, I could put
mysite.com/offers/bikes/weekly
mysite.com/offers/bikes.aspx?period=weekly
I would have in my script that nothing but the weekly has been set, so just show ALL weeks.
This will allow me to set various offers by week number. I should point out that this is a complete fabrication. It's just an example to see if it's possible??
Hope this is possible as at the moment if I leave off any parameters, it says page cannot be found.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是添加问号以将参数标识为“可选”的情况。
例如,([_0-9a-zA-Z]+)/?([_0-9a-zA-Z-])/?([_0-9a-zA-Z-]) /?$
(最后两个元素是可选的)
在这里找到答案:具有可选 1、2 或 3 个值的简单 IIS 7 正则表达式
It was a case of adding question marks to identify a parameter as "optional".
For example, ([_0-9a-zA-Z]+)/?([_0-9a-zA-Z-])/?([_0-9a-zA-Z-])/?$
(last two elements are optional)
Answer found here: Simple IIS 7 regex with optional 1, 2 or 3 values