如何在ISAPI_Rewrite中重定向页面 [英] How to redirect a page in ISAPI_Rewrite

查看:79
本文介绍了如何在ISAPI_Rewrite中重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ISAPI_Rewrite v2 ,并且我有以下规则:

I use ISAPI_Rewrite v2 and I have this rules:

    RewriteRule ^/cnvrt$ /convert [I,RP]
    RewriteRule ^/convert$ /convert.aspx [I,L]

我希望每当有人进入site.com/cnvrt时,它将他重定向到site.com/convert

I want that whenever someone enter site.com/cnvrt it will redirect him to site.com/convert

上述规则的问题在于,它只是放置了一个窗口,该页面显示可以在此url下找到该页面:.... 我想要的是将其重定向到页面(URL将会更改)

The problem with the above rule is that it just put a window that says the page can be found under this url: .... And what I want is to it redirect him to the page(that the url will change)

我不想在代码级别处理它.

I dont want to handle it in the code level.

我该怎么做?

谢谢

推荐答案

这是一个好方案,将旧的重写URL永久重定向为301重定向到新的URL,然后将该新的URL重写到页面.

This is a good scenario, redirecting an old rewrite url to a new one permanently as a 301 redirect, then rewriting that new url to the page.

尝试以下v3规则:

RewriteRule ^/cnvrt$ /convert [NC,R=301]
RewriteRule ^/convert$ /convert.aspx [NC,L]

您使用的是哪个版本:v2或v3?

What version are you using: v2 or v3?

有趣的是,我在v3下尝试了您的v2规则,它们按照您所说的进行了操作,但是没有重定向.我认为原因是第一个规则将/cnvrt重写为/convert,但是RP不是重定向语法.没有重定向,最后也没有L,因此它进入了下一条规则,该规则将/convert重写为/convert.aspx页.

Interestingly, I tried your v2 rules under v3, and they did just what you said, rewriting but not redirecting. I think the reason is that the first rule rewrites /cnvrt to /convert, but RP isn't the redirect syntax. There's no redirect and no L for last, so it falls through to the next rule, which rewrites /convert to /convert.aspx page.

这篇关于如何在ISAPI_Rewrite中重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆