简体   繁体   English

使用IIS的URL重写模块将下划线替换为破折号

[英]replace underscore with dash using url rewrite module of iis

I have issue regarding Url rewrite module. 我有关于网址重写模块的问题。

I want to implement permanent redirect (301) into my site. 我想对我的网站实施永久重定向(301)。 and url is, I want to permanently redirect 和网址是,我想永久重定向

http://demo.datadiary.com/search/product/ahmedabad/ac_dealers http://demo.datadiary.com/search/product/ahmedab​​ad/ac_dealers

url to 网址至

http://demo.datadiary.com/search/product/ahmedabad/ac-dealers http://demo.datadiary.com/search/product/ahmedab​​ad/ac-dealers

Thanks in advance. 提前致谢。

I got the solution. 我找到了解决方案。 put the following into your web.config, but keep in mind that your host must have installed Url rewrite module in iis. 将以下内容放入您的web.config中,但请记住,主机必须在iis中安装了Url重写模块。

<rule name="Imported Rule 1-2" stopProcessing="true">
                    <match url="(search/product/ahmedabad.*/[^/]*?)_([^/_]*)$" ignoreCase="false" />
                    <action type="Redirect" url="{R:1}-{R:2}" redirectType="Permanent" />
                </rule>

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

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