简体   繁体   English

如何在 ISAPI_Rewrite 中重定向页面

[英]How to redirect a page in ISAPI_Rewrite

I use ISAPI_Rewrite v2 and I have this rules:我使用 ISAPI_Rewrite v2并且有以下规则:

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

I want that whenever someone enter site.com/cnvrt it will redirect him to site.com/convert我希望每当有人输入 site.com/cnvrt 时,它都会将他重定向到 site.com/convert

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)上述规则的问题在于,它只是放了一个 window,表示该页面可以在此 url 下找到:....而我想要的是将他重定向到该页面(Z572D4E421E5E6B9BC11D815E8 将更改)

I dont want to handle it in the code level.我不想在代码级别处理它。

How can I do this?我怎样才能做到这一点?

Thanks谢谢

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.这是一个很好的方案,将旧的重写 url 作为 301 重定向永久重定向到新的重写,然后将新的 url 重写到页面。

Try these v3 rules:试试这些 v3 规则:

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

What version are you using: v2 or v3?您使用的是什么版本:v2 还是 v3?

Interestingly, I tried your v2 rules under v3, and they did just what you said, rewriting but not redirecting.有趣的是,我在 v3 下尝试了你的 v2 规则,他们就按照你说的做了,重写但不重定向。 I think the reason is that the first rule rewrites /cnvrt to /convert, but RP isn't the redirect syntax.我认为原因是第一条规则将 /cnvrt 重写为 /convert,但 RP 不是重定向语法。 There's no redirect and no L for last, so it falls through to the next rule, which rewrites /convert to /convert.aspx page.没有重定向,也没有最后一个 L,所以它落入下一条规则,将 /convert 重写为 /convert.aspx 页面。

[I,RP] are used in ISAPI_Rewrite 2 [NC,R=301] are for ISAPI_Rewirte 3 [I,RP] 用于 ISAPI_Rewrite 2 [NC,R=301] 用于 ISAPI_Rewirte 3

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

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