Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0 support forum
 Helicon Tech : ISAPI_Rewrite 3.0 support forum
Subject Topic: Url Rewriting with partial Query String Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
LaptopHeaven
Newbie
Newbie


Joined: 09 July 2008
Online Status: Offline
Posts: 3
Posted: 09 July 2008 at 3:07pm | IP Logged Quote LaptopHeaven

I am having trouble setting up the proper rewrite rule for my situation.


I want to redirect the following urls
/viewstory.asp?id=1234 TO /article/1234.htm
/viewstory.asp?id=1234&source=xxxx TO /article/1234.htm?source=xxxx
/viewstory.asp?id=1234[&abc=xxxx] TO /article/1234.htm?abc=xxxx

then server side rewrite the urls back to the orignal
/article/1234.htm TO /viewstory.asp?id=1234
/article/1234.htm?source=xxxx TO /viewstory.asp?id=1234&source=xxxx
/article/1234.htm?abc=xxxx TO /viewstory.asp?id=1234[&abc=xxxx]

I have the following rules right now, but the additional querystring is still causing issues.

#  rule to redirect content to a permalinked page.
RewriteRule ^/viewstory\.asp\?id=([0-9]*)(.*)$ /article/$1.htm [NC,R=301]
RewriteRule ^/viewstory\.asp\?id=([0-9]*)$ /article/$1.htm [NC,R=301]

RewriteRule ^/article/([0-9]*).htm(.*)$ /viewstory.asp?id=$1 [NC,L]
RewriteRule ^/article/([0-9]*)/(.*).htm(.*)$ /viewstory.asp?id=$1 [NC,L]


Back to Top View LaptopHeaven's Profile Search for other posts by LaptopHeaven
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4146
Posted: 10 July 2008 at 2:35am | IP Logged Quote Anton

Please try the following config:

RewriteCond %{QUERY_STRING} ^id=(\d+)(&(.+))?$ [NC]
RewriteRule ^/viewstory\.asp$ /article/%1.htm?%2\?%3? [NC,R=301]

RewriteRule ^/article/(\d+)\.htm$ /viewstory.asp?id=$1 [NC,L,QSA]


__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
LaptopHeaven
Newbie
Newbie


Joined: 09 July 2008
Online Status: Offline
Posts: 3
Posted: 10 July 2008 at 8:08am | IP Logged Quote LaptopHeaven

There's no redirection happening at all.
ie: viewstory.asp?id=1234 does not redirect nor does viewstory.asp?id=1234&source=xyz


Back to Top View LaptopHeaven's Profile Search for other posts by LaptopHeaven
 
Vyacheslav
Moderator Group
Moderator Group


Joined: 02 July 2008
Location: Ukraine
Online Status: Offline
Posts: 578
Posted: 10 July 2008 at 8:25am | IP Logged Quote Vyacheslav

Hi LaptopHeaven!

Please try this solution:
Code:
RewriteCond %{QUERY_STRING} ^id=(\d+)(?:&([a-zA-Z0-9]+)=([^/]+))?$ [NC]
RewriteRule ^viewstory\.asp$ article/%1.htm?%2=%3? [NC,R=301]
RewriteRule ^article/(\d+)\.htm$ viewstory.asp?id=$1 [NC,L,QSA]



__________________
Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
Back to Top View Vyacheslav's Profile Search for other posts by Vyacheslav Visit Vyacheslav's Homepage
 
LaptopHeaven
Newbie
Newbie


Joined: 09 July 2008
Online Status: Offline
Posts: 3
Posted: 10 July 2008 at 8:56am | IP Logged Quote LaptopHeaven

This line is still not executing:
RewriteRule ^viewstory\.asp$ article/%1.htm?%2=%3? [NC,R=301]
   
Back to Top View LaptopHeaven's Profile Search for other posts by LaptopHeaven
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4146
Posted: 11 July 2008 at 2:49am | IP Logged Quote Anton

Please provide rewrite log records for the specific request matching above line.


__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum