ReWrite a URL and then ReWrite it again?

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 29 Apr 2013, 16:57

ReWrite a URL and then ReWrite it again?

29 Apr 2013, 17:03

I'm trying to rewrite page to another page, but that page also has to be rewritten to a more friendly URL. There has to be a better way to do this. What I have right now isn't working. I'm sure it's something small. Anyone's help would be much appreciated.

Code: Select all
RewriteRule index.cfm?areaCat=events /stealsanddeals/events/ [R=301,NC,L,NS]
RewriteRule ^stealsanddeals/events/?$ events.cfm?areaCat=upcomingevents [NC,L,NS]


The first line is rewriting the current URL to the new "friendly" URL (doesn't work). The second line is designed to rewrite the friendly URL displaying the files in the second part of the line. The second line DOES work by itself.

Again, I'm sure it's very simple or maybe there is a a flat better way to do it.

Thanks in advance for your assistance.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: ReWrite a URL and then ReWrite it again?

30 Apr 2013, 13:37

Hello,

Yes, it is small.
Try to replace the first rule with:

Code: Select all
RewriteCond %{QUERY_STRING} ^areaCat=events$ [NC]
RewriteRule ^index\.cfm /stealsanddeals/events/ [R=301,NC,L]


Probably, you also do not need to use NS flag.

Regards
Andrew

User avatar
Posts: 3
Joined: 29 Apr 2013, 16:57

Re: ReWrite a URL and then ReWrite it again?

30 Apr 2013, 14:55

Excellent. I knew it was something simple. I did append a ? to the end of the RewriteRule as it was still tossing the querystring on the back of the new URL

domain.com/stealsanddeals/events/?areaCat=events

So, by changing it to the following:
RewriteCond %{QUERY_STRING} ^areaCat=events$ [NC]
RewriteRule ^index\.cfm /stealsanddeals/events/? [R=301,NC,L]

I got the following which was exactly what I was looking for:
domain.com/stealsanddeals/events/

Thanks so much for the quick help! You rock.

Great product guys!

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 19 guests