Welcome to WebmasterWorld Guest from 52.91.39.106

Forum Moderators: ocean10000

Message Too Old, No Replies

Helicon Ape IIS RewriteRule

Isapi rewrite 301 redirect

     
3:54 am on Nov 15, 2011 (gmt 0)

New User

10+ Year Member

joined:Mar 18, 2008
posts: 9
votes: 0


Hello.

I have the following 2 lines in Helicon Ape
-----------

RewriteRule ^photos.asp?id=([0-9]*) /photos/$1 [R=301,L]

RewriteRule ^photos/([0-9]*)$ photos.asp?id=$1

-----------
Line 2 works fine. So the page is being displayed no problem.

However, line 1 does not work. I want any requests for /photos.asp?id=12345 to be 301 redirected to /photos/12345 in the address bar.

Hope I explained that well enough. What am I doing wrong here? Any help is greatly appreciated.

Thanks!
Mike
1:14 pm on Nov 15, 2011 (gmt 0)

New User

5+ Year Member

joined:Nov 15, 2011
posts:5
votes: 0


Please try this code instead:

RewriteCond %{QUERY_STRING} id=([0-9]*)
RewriteRule ^photos.asp /photos/%1 [R=301,L]

RewriteRule ^photos/([0-9]*)$ photos.asp?id=$1
4:46 pm on Nov 15, 2011 (gmt 0)

New User

10+ Year Member

joined:Mar 18, 2008
posts: 9
votes: 0


Thank you very much for the suggestion. I'm still have an issue but getting close.

Looking on Helicon Ape support, turns out you need a ? after the %1 to stop it from appending the querystring to the end of the URL after redirect. (Note: Helicon Ape uses Isapi Rewrite 3). Here is the code I'm using now.
-----------

RewriteCond %{QUERY_STRING} id=([0-9]*)
RewriteRule ^photos.asp /photos/%1? [R=301,L]

RewriteRule ^photos/([0-9]*)$ photos.asp?id=$1


-----------
Now... I try the following url:
www.mysite.com/photos.asp?id=123

If I use the Rewrite part only (line 3) the page will display fine, but a redirect won't happen, which makes sense.

If I use the redirect part only (Lines 1 & 2). And comment out line 3, I get a redirect to www.mysite.com/photos/123 but the page won't render. Also makes sense.

Using them all 3 lines together, it bombs. Seems like maybe there is some loop going on (?).

I'm getting close but need another suggestion.

Thanks for any help.

Mike
9:18 pm on Nov 15, 2011 (gmt 0)

New User

5+ Year Member

joined:Nov 15, 2011
posts: 5
votes: 0


You are right about tailing "?" sign, I forgot that in redirects query string is appended automatically, so you need to reset it explicitely if you don't need it.

As for looping this problem usually happen if you have double registration of module. For example you have both Helicon Ape and ISAPI_Rewrite installed on your server or have doubled these rules in httpd.conf and .htaccess. If you have ISAPI_Rewrite 3 - remove it and use Ape alone.
11:22 pm on Nov 15, 2011 (gmt 0)

New User

10+ Year Member

joined:Mar 18, 2008
posts: 9
votes: 0


I only have Helicon installed, so it's probably not that.

Strange that I have the following working fine with redirect and all.

RewriteRule ^mypage-([0-9]*).htm $1 [R=301,L]
RewriteRule ^([0-9]+)$ mypage.asp?id=$0


But for some reason this other one with querystring is not.

Let me know if you come up with any other ideas.

Thanks again,

Mike
8:42 am on Nov 16, 2011 (gmt 0)

New User

5+ Year Member

joined:Nov 15, 2011
posts: 5
votes: 0


I will explain how your redirect looping work:
First your initial rules are applied. If URL is original (with query string) user gets redirect, if URL is new one with number it gets rewritten to original for further processing by server. Then another instance of same rules or module come on, and if URL is original (rewritten to original on previous step) then user gets redirected, and so on.
So this is quite evident you have two instances of this rules applied to a single request, the question is where. Possibly you have registered Helicon Ape on your site's web.config without removing it from global application.host.config? If you cannot find another instance of rules please contact Helicon Tech support service, we will try to help you with RDP.
5:26 pm on Nov 16, 2011 (gmt 0)

New User

10+ Year Member

joined:Mar 18, 2008
posts: 9
votes: 0


I see Helicon in application.host.config but it is not in the web.config for this website.

Would the following redirect work if there were a double registration or loop? Because it is working fine.

RewriteRule ^mypage-([0-9]*).htm $1 [R=301,L]
RewriteRule ^([0-9]+)$ mypage.asp?id=$0
10:05 pm on Nov 17, 2011 (gmt 0)

New User

5+ Year Member

joined:Nov 15, 2011
posts: 5
votes: 0


Yes it will work because redirect and rewrite part in these rules are different.
Please open ticket on Helicon Tech support if you want to get further help. Please provide link to this post in the ticket.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members