0

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

Nir
  • 2,497
  • 9
  • 42
  • 71

2 Answers2

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.

goodeye
  • 2,389
  • 6
  • 35
  • 68
  • I'm using v2, So how can I do this redirecting? – Nir Jul 23 '11 at 15:13
  • Your rules look right for v2, but I'll test it and see. What is the name of your rules file? httpd.ini or .htaccess? – goodeye Jul 23 '11 at 22:49
  • Its .ini , ISAPI Rewrite identify this rule(I know this because I get to the "your oage can be found here..") but its doesnt perform redirection. – Nir Jul 24 '11 at 18:28
  • I tried your rules in your question in v2, and they worked for me. I was about to suggest turning on logging, but just learned that v3 has logging, but v2 does not. Maybe fiddler2 will help confirm it. Try the same rules but with different filenames, like cnvrt2, convert2 - I've been having trouble with google chrome caching my first try, and not following my changes. Other than that, consider upgrading to v3 - I had to get used to it, but once I did, it got easier. I haven't tried Ape yet - they're recommending that for IIS7. – goodeye Jul 24 '11 at 18:56
  • I cant upgrade to v3. Did the page redirect to /convert (I mean does it change the showing url to site.com/convert)? Or its just said the page can be found in site.com/convert ? – Nir Jul 26 '11 at 17:10
  • Hi, in both cases of using v3 rules on v3, and v2 rules on v2, it actually redirected, showing the /convert url. It was only in the mismatched case where I tried v2 rules on v3 that it just said page can be found. Maybe try entirely different page names, just in case the browser is involved, like /tstold and /testnew – goodeye Jul 26 '11 at 19:17
0

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

Andrew
  • 511
  • 3
  • 7