This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Redirect All Pages With QueryString?
Author
Message |
leen3o
Newbie


Joined: 13 October 2008
Location: United Kingdom
Posts: 14
Posted: 31 August 2011 at 8:47am

I need to redirect all mypage.htm with any querystring
like so

/mypage.htm?e=547
/mypage.htm?e=5445
/mypage.htm?e=456
/mypage.htm?e=123

I tried this but its not working?

RewriteRule ^mypage.htm$ /some-new-page/ [R=301,L]

Can you let me know the syntax?
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 31 August 2011 at 9:06am

Should the query-string migrate to destination URL? I mean, do you need /some-new-page/?e=547 or /some-new-page/ ?

__________________
Regards,
Anton
Back to Top
 
leen3o
Newbie


Joined: 13 October 2008
Location: United Kingdom
Posts: 14
Posted: 31 August 2011 at 9:17am

No I don't need it, I just want it to redirect to the new
page.

(Could you give an example with and without including it?)
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 31 August 2011 at 9:33am

By default, if destination doesn't have its own query string, the requested query string will be appended.
If you don't want it (it's your case), "?" should be added at the end of substitution like this:

RewriteBase /
RewriteCond %{QUERY_STRING} .+
RewriteRule ^mypage\.htm$ /some-new-page/? [R=301,L]

__________________
Regards,
Anton
Back to Top
 
leen3o
Newbie


Joined: 13 October 2008
Location: United Kingdom
Posts: 14
Posted: 31 August 2011 at 12:30pm

That is awesome thanks - But I have one last question if
thats ok. I need to redirect any page that is in this
/custom/ folder and ends with .aspx to a specific page.

For example

/custom/any-page-name-897.aspx
/custom/another-page-name-8897.aspx

And redirect these ALL to

/new-custom-page/

Is this easily acheived?
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 01 September 2011 at 12:22am

Pretty easily :)

RewriteRule ^custom/[^.]+\.aspx$ /new-custom-page/? [NC,R=301,L]

__________________
Regards,
Anton
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version