Topic: Url Rewriting with partial Query String
|

|
| Author |
|
LaptopHeaven Newbie

Joined: 09 July 2008
Online Status: Offline Posts: 3
|
| Posted: 09 July 2008 at 3:07pm | IP Logged
|
|
|
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 |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 3895
|
| Posted: 10 July 2008 at 2:35am | IP Logged
|
|
|
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 |
|
| |
LaptopHeaven Newbie

Joined: 09 July 2008
Online Status: Offline Posts: 3
|
| Posted: 10 July 2008 at 8:08am | IP Logged
|
|
|
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 |
|
| |
Vyacheslav Moderator Group

Joined: 02 July 2008 Location: Ukraine
Online Status: Offline Posts: 350
|
| Posted: 10 July 2008 at 8:25am | IP Logged
|
|
|
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.
|
| Back to Top |
|
| |
LaptopHeaven Newbie

Joined: 09 July 2008
Online Status: Offline Posts: 3
|
| Posted: 10 July 2008 at 8:56am | IP Logged
|
|
|
This line is still not executing:
RewriteRule ^viewstory\.asp$ article/%1.htm?%2=%3? [NC,R=301]
|
| Back to Top |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 3895
|
| Posted: 11 July 2008 at 2:49am | IP Logged
|
|
|
Please provide rewrite log records for the specific request matching above line.
__________________ Regards,
Anton
|
| Back to Top |
|
| |
|
|
If you wish to post a reply to this topic you must first login
If you are not already registered you must first register
|
|
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
|