Help with 301 redirect to new website

Topics: Developer Forum
Oct 4, 2009 at 1:19 AM

Hi,

I built a new website and want to redirect the pages on the old site to the new one. My webhost installed iirf when I asked them about ISAP_Rewrite.

I read the manual and followed what was on the  RedirectRule page.

I took this example of the syntax: RedirectRule ^/(W.*)$ http://server.dyndns.org:7070/$1 [R=301]

and tried modifying it to fit my needs. I've tried these ways of doing it.

  1. RedirectRule ^/aboutus\.aspx$ diversitymbamagazine.com/about-2$ [R=301]
  2. RedirectRule ^/(aboutus.*)$ diversitymbamagazine.com/about-2 $1 [R=301]
  3. RedirectRule ^/aboutus\.aspx$ diversitymbamagazine.com/about-2 [R=301]
  4. RedirectRule ^/aboutus.aspx$ diversitymbamagazine.com/about-2$ [R=301]
  5. RedirectRule ^/aboutus.aspx$ diversitymbamagazine.com/about-2/$ [R=301]

None of them have worked. I also tried using the absolute URL for the old site instead of a relative one.

I went into the log files and a couple of things pop out at me.

In some of the sets of entries, it looks like its going through my directories looking for something to match the rule to, but isn't finding anything.

Example:

New Url: '/profileimages/c30UnitedDefenceLogo.gif'
Sat Oct 03 15:46:49 2009 - ApplyRules (depth=0)
Sat Oct 03 15:46:49 2009 - Rule 1 : -1 (No match)
Sat Oct 03 15:46:49 2009 - ApplyRules: returning 0
Sat Oct 03 15:46:49 2009 - No Rewrite

But in another set of entries, it shows the right URL, but does not execute the directive.

Example:

Sat Oct 03 16:17:06 2009 - New Url: '/aboutus.aspx'
Sat Oct 03 16:17:06 2009 - ApplyRules (depth=0)
Sat Oct 03 16:17:06 2009 - Rule 1 : -1 (No match)
Sat Oct 03 16:17:06 2009 - ApplyRules: returning 0

Maybe I'm reading this stuff wrong? But that's what I notice.

Can someone please provide me an example of the syntax I'd use to redirect this page http://www.dricareers.com/aboutus.aspx to this page http://diversitymbamagazine.com/about-2 ? Or maybe just some hints?

I'll admit I'm a noob. Not embarrassed about it. Just looking for a little help.

Thanks

 

 

Coordinator
Oct 4, 2009 at 8:10 AM

The first log snip you showed was a request for a .gif file.  It's not "going through your directories" - and I don't know what you mean by that.  The web page has a .gif in it, and IIRF is checking to see if any of the rules match that .gif.  No rules match, so you get no rewrite (and no redirect).

The second log snip you showed was for the .aspx page - it also does not match the single rule you have. 

The one thing I cannot see from the log snips is the rule you are using.  In the initial part of the logfile , there will be some statements indicating the rules that are loaded.  I cannot see that.

On the other hand, the rules you're showing seem to be correct - they should match.  One problem though - why did you remove the http:// prefix on from the redirect target?  It should be http://diversitywhatever.com/about-2  .  I'm not sure if those rules will be parsed correctly, without the prefix.  You should be able to see this in the log file, but as I said before, you didn't include the initial part of the logfile so I can't tell.

Also - the replacement pattern should not get a terminating $. 

I know you said you are new to this stuff, but I would recommend not using IIRF in production if you have not read the documentation.

 

Oct 4, 2009 at 3:23 PM

Last snippet of log. I will reply to your comments in another post.

Sat Oct 03 17:03:45 2009 - LogFile re-opened.
Sat Oct 03 17:03:54 2009 - HttpFilterProc SF_NOTIFY_URL_MAP
Sat Oct 03 17:03:54 2009 - HttpFilterProc SF_NOTIFY_AUTH_COMPLETE
Sat Oct 03 17:03:54 2009 - DoRewrites
Sat Oct 03 17:03:54 2009 - New Url: '/'
Sat Oct 03 17:03:54 2009 - ApplyRules (depth=0)
Sat Oct 03 17:03:54 2009 - Rule 1 : -1 (No match)
Sat Oct 03 17:03:54 2009 - ApplyRules: returning 0
Sat Oct 03 17:03:54 2009 - No Rewrite
Sat Oct 03 17:03:54 2009 - HttpFilterProc SF_NOTIFY_URL_MAP
Sat Oct 03 17:03:54 2009 - HttpFilterProc SF_NOTIFY_URL_MAP
Sat Oct 03 17:03:54 2009 - HttpFilterProc SF_NOTIFY_URL_MAP
Sat Oct 03 17:03:57 2009 - HttpFilterProc SF_NOTIFY_URL_MAP
Sat Oct 03 17:03:57 2009 - HttpFilterProc SF_NOTIFY_AUTH_COMPLETE
Sat Oct 03 17:03:57 2009 - DoRewrites
Sat Oct 03 17:03:57 2009 - New Url: '/aboutus.aspx'
Sat Oct 03 17:03:57 2009 - ApplyRules (depth=0)
Sat Oct 03 17:03:57 2009 - Rule 1 : -1 (No match)
Sat Oct 03 17:03:57 2009 - ApplyRules: returning 0
Sat Oct 03 17:03:57 2009 - No Rewrite
Sat Oct 03 17:03:57 2009 - HttpFilterProc SF_NOTIFY_URL_MAP
Sat Oct 03 17:03:57 2009 - HttpFilterProc SF_NOTIFY_URL_MAP
Sat Oct 03 17:04:04 2009 - DllMain THREAD_DETACH, threadId= 6104
Sat Oct 03 17:04:04 2009 - DllMain THREAD_DETACH, threadId= 7696
Sat Oct 03 17:04:04 2009 - DllMain THREAD_DETACH, threadId= 9260
Sat Oct 03 17:04:04 2009 - DllMain THREAD_DETACH, threadId= 6376
Sat Oct 03 17:04:04 2009 - DllMain THREAD_DETACH, threadId= 916
Sat Oct 03 17:05:04 2009 - DllMain THREAD_DETACH, threadId= 6244

Coordinator
Oct 4, 2009 at 3:28 PM
Edited Oct 4, 2009 at 3:29 PM

The last snippet doesn't help.  As I said, It's the initial part I need.  But why are you snipping it out anyway? 

The log is there to help diagnose these situations. If you withhold it, I can't help you.

 

Oct 4, 2009 at 3:47 PM

The first log snip you showed was a request for a .gif file.  It's not "going through your directories" - and I don't know what you mean by that.  The web page has a .gif in it, and IIRF is checking to see if any of the rules match that .gif.  No rules match, so you get no rewrite (and no redirect).

In every attempt I make, I give an exact file extension (.aspx). So it didn't make since to me that it should be looking at .gifs or anything else in a page. Also, if its a redirect, Shouldn't it be responding to the server request. Why would it look through everything on the page? My interpretation of the log file was that it was trying to match to a file on the system. Your documentation does not explain this.

Also - the replacement pattern should not get a terminating $.

I use the terminating $ because you  do in your examples:

RedirectRule ^/(W.*)$  http://server.dyndns.org:7070/$1  [R=301]

I read the part in the section on regualar expressions that says the $1 is to identify a group. But that page doesn't make it clear if the terminating $ is needed in all cases or just when you want to identify that group.

why did you remove the http:// prefix on from the redirect target?

I will add this and see if anything works differently.

For the record, I read your manual. Its not particularly clear on any of the issues you point out here. Think about how much traffic this discussion group gets: If your documentation was that great, do you really think you'd have regular posts to respond to? People come here with different levels of knowledge, but even experienced guys end up coming here because a lot of documentation is poorly organized and vague. You give poor examples and there is nothing intuitive about your approach to the topics.

I appreciate that you do this for free. I thank you for your help. But maybe you should work on your communication skills. I didn't ask for your software, I got stuck with it.  I'm looking for answers, not condescension. I've done this same task on 4 other sites with ISAPI_Rewrite. And about 5 sites with Apache  mod_rewrite.

The final statement in your response is rude & unnecessary:

I know you said you are new to this stuff, but I would recommend not using IIRF in production if you have not read the documentation.

WTF?

The first log snip you showed was a request for a .gif file.  It's not "going through your directories" - and I don't know what you mean by that.  The web page has a .gif in it, and IIRF is checking to see if any of the rules match that .gif.  No rules match, so you get no rewrite (and no redirect).

The second log snip you showed was for the .aspx page - it also does not match the single rule you have. 

The one thing I cannot see from the log snips is the rule you are using.  In the initial part of the logfile , there will be some statements indicating the rules that are loaded.  I cannot see that.

On the other hand, the rules you're showing seem to be correct - they should match.  One problem though - why did you remove the http:// prefix on from the redirect target?  It should be http://diversitywhatever.com/about-2  .  I'm not sure if those rules will be parsed correctly, without the prefix.  You should be able to see this in the log file, but as I said before, you didn't include the initial part of the logfile so I can't tell.

Also - the replacement pattern should not get a terminating $. 

I know you said you are new to this stuff, but I would recommend not using IIRF in production if you have not read the documentation.

 

Coordinator
Oct 4, 2009 at 4:47 PM

> n every attempt I make, I give an exact file extension (.aspx). So it didn't make since to me that it should be looking at .gifs or anything else in a page.

Ah ok. Well the reason your browser is asking for .gifs is that the webpage has an image in it.  First the browser requests the page. Then the browser looks in the page content and makes new requests for any linked resources.  this can be images (gif png jpg etc), stylesheets (css), scripts (.js) and other stuff.  I don't know what your aboutus.aspx page looks like, but I'll bet it has a reference to an image within it.

> I use the terminating $ because you  do in your examples:

You're misunderstanding.  The terminating $ appears in the pattern, sometimes.  In the replacement string, the $ has a different meaning. It precedes a digit, and it acts as a reference to a captured substring.  In your examples, you have $ as the last char in the replacement pattern. This is wrong.  Also, it is not consistent with the example you cited from the doc.

> For the record, I read your manual. Its not particularly clear on any of the issues you point out here. Think about how much traffic this discussion group gets: If your documentation was that great, do you really think you'd have regular posts to respond to?

Listen I'm sorry you're having trouble. If you recall, this is FREE software, and I do this without compensation of any kind. Your attitude is not going to persuade me to help you.  It seems to me, if I am explaining basic HTTP operation to you (see my first answer here), then the problem with your lack of understanding of the manual, is not with the manual. 

> maybe you should work on your communication skills.

Thanks for your advice.  Please don't come back.