简体   繁体   中英

How to redirect a page in ISAPI_Rewrite

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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