URL Rewriter and IIS configuration

Suppose you want to use http://XXX/aa-bb  as your displayed url, but you want to remove the extension from your URL and the actual URL is http://XXX/aa-bb.aspx. You can write some codes by yourself to implement URL Rewriting feature.

 

But there is a problem. The code only works on dev box. when hosted in production I keep getting 404s error when requesting http://XXX/aa-bb, only http://XXX/aa-bb.aspx can work.

 

So you got to do some configuration in IIS to solve this problem. Dont't forget that mapping "*all*" requests to asp.net. Here is how-to:

 

In IIS6, go to home directory tab, click "configuration" and "add a wildcard map to the following file ".

browse to "c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll" and enter .*

ensure that 'check that file exists' is unchecked.

 

But everything has two sides. It will slow down the performance more or less. secondly, by unchecking "check that file exists" will bring about another problem you will experience. You can not utilize the Error 404 ability provided by IIS to catch error 404 'file not found' to redirect your request to a page you specify.

 

There is another way to implement URL rewriter. You can use error 404 ability to get the request like "http://XXX/aa-bb" in the aspx page you specify in IIS and then transfer this page to the phisical page you want. But the head status in response for this aspx page will be changed to 404 and the header might be rewrited, which will cause some problems when your websites are required to do SEO since some websites spiders and crawers will ignore error 404 and stop processing this page. Secondly, the css or js defined in the header might reference to wrong link path. I ran into this problem. But actually I don't know exactly what happened inside.

 

There is one tiny thing we need to notice. When you implement URL rewriter, Suppose you have a displayed URL, Let's say  http://XXX/newview/Military", and you want to rewrite it to http://XXX/newview.aspx?Title=Military.

As you can see here, the directory path level is decreased from 2 to 1. So when you use css link like "../css/global.css" you cannot find the css file. So you need to use Resolve("~/Css/global.css") method provided by asp.net.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]和\[2\]提供了关于在IIS中部署chatgpt-next-web的配置示例。根据这些示例,你可以按照以下步骤进行部署: 1. 首先,你需要修改web.config文件。根据\[1\]中的示例,你需要将url rewriter节中的index.js/debug地址设置为不匹配negate="true"。这可以通过在rewrite规则中添加`<match url="index.js/debug" negate="true" />`来实现。 2. 接下来,你需要创建一个Web.config文件并将其放置在chatgpt-next-web目录中。根据\[2\]中的示例,你需要在该文件中添加iisnode的处理程序和rewrite规则。处理程序的路径应该指向chatgpt-next-web的启动程序,例如`bin/www`。 3. 确保bin目录是chatgpt-next-web的默认输出目录,并允许模块调用。这可以通过在Web.config文件中设置正确的路径来实现。 4. 最后,你可以在浏览器中打开`http://localhost/myapp/`来访问chatgpt-next-web应用程序。如果一切配置正确,你应该能够成功访问应用程序。 需要注意的是,这只是一个示例配置,具体的部署过程可能因你的环境和需求而有所不同。你可能需要根据实际情况进行适当的调整和配置。 #### 引用[.reference_title] - *1* *2* [crossplatform---Nodejs in Visual Studio Code 10.IISNode](https://blog.csdn.net/weixin_33991727/article/details/93280120)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [JSP住宅小区物业管理系统(源代码+开题报告+论文+答辩PPT)](https://blog.csdn.net/m0_73546099/article/details/130682154)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值