URL Rewrite with QueryString

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 4
Joined: 05 Jun 2012, 15:19

URL Rewrite with QueryString

05 Jun 2012, 15:33

Hello all-

I need to create friendly URLs for several dynamic pages. I have version 3.0 full. I have part of it working, but I'm relatively new to ISAPI Rewrite, so I don't know how to do the other part.

1) This part is currently working. If a visitor types or clicks on the friendly URL (http://www.domain.com/friendlyurl), the address bar displays the friendly URL and the dynamic content from default.aspx?id=1.

RewriteRule ^/friendlyurl$ /default.aspx?id=1 [NC, L]

2) I would like to add the opposite as well. So that if a visitor clicks on the URL to the dynamic page (http://www.domain.com/aspx?id=1), the address bar displays the friendly URL instead of the default.aspx?id=1. I tried the following:

RewriteCond %{QUERY_STRING} ^id=1$ [NC]
RewriteRule ^defualt\.aspx /friendlyurl [NC,L]


Thanks in advance!

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

Re: URL Rewrite with QueryString

06 Jun 2012, 06:44

Hello,

1) A possible misprint: defualt instead of default
2) Please, try using the following:

Code: Select all
RewriteCond %{QUERY_STRING} ^id=1$ [NC]
RewriteRule ^/default\.aspx$ /friendlyurl? [NC,R=301,L]


Regards
Andrew

User avatar
Posts: 4
Joined: 05 Jun 2012, 15:19

Re: URL Rewrite with QueryString

06 Jun 2012, 11:20

Andrew-

Thanks for the reply. Yes, I did have a typo in my code, but it didn't seem to fix it. I tried the code you provided and it does rewrite the header, but I get a page not found.

Thanks!

-Karen

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

Re: URL Rewrite with QueryString

06 Jun 2012, 11:44

Please, provide rewrite.log for the testing request.
Logging issues described in FAQ

Regards
Andrew

User avatar
Posts: 4
Joined: 05 Jun 2012, 15:19

Re: URL Rewrite with QueryString

07 Jun 2012, 16:52

Andrew-

Attached is my log file. THe actual querystring I am using is ?ID=193 (I had used a '1' for my original post). I actually switched around where I was loading the rewrite and it is now in the htaccess file insetad of the httpd.conf file. I am no longer getting page not found errors, but it is not rewriting the URL with the original code or the code you provided. The IP for my computer is: 10.152.129.240, if you want to narrow down the log file.

Thanks for your help.

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

Re: URL Rewrite with QueryString

08 Jun 2012, 05:27

Please, attach the log.

Regards
Andrew

User avatar
Posts: 4
Joined: 05 Jun 2012, 15:19

Re: URL Rewrite with QueryString

08 Jun 2012, 08:40

Log attached.
Attachments
Rewrite.zip
(43.21 KiB) Downloaded 1361 times

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

Re: URL Rewrite with QueryString

08 Jun 2012, 09:47

Hello,

Simply remove '/' in fron of "default":

Code: Select all
RewriteCond %{QUERY_STRING} ^id=1$ [NC]
RewriteRule ^default\.aspx$ /friendlyurl? [NC,R=301,L]


Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 14 guests