URL Rewrite with QueryString
8 posts
• Page 1 of 1
URL Rewrite with QueryString
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!
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!
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: URL Rewrite with QueryString
Hello,
1) A possible misprint: defualt instead of default
2) Please, try using the following:
Regards
Andrew
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
Re: URL Rewrite with QueryString
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
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
Re: URL Rewrite with QueryString
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: URL Rewrite with QueryString
Please, attach the log.
Regards
Andrew
Regards
Andrew
Re: URL Rewrite with QueryString
Log attached.
- Attachments
-
- Rewrite.zip
- (43.21 KiB) Downloaded 1361 times
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: URL Rewrite with QueryString
Hello,
Simply remove '/' in fron of "default":
Regards
Andrew
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
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 14 guests