How to redirect a page in ISAPI_Rewrite

跟風遠走 提交于 2019-12-24 20:26:16

问题


I use ISAPI_Rewrite v2 and I have this rules:

    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

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.

How can I do this?

Thanks


回答1:


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.

Try these v3 rules:

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

What version are you using: v2 or v3?

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.




回答2:


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



来源:https://stackoverflow.com/questions/6766354/how-to-redirect-a-page-in-isapi-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!