Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: 301 redirect for query-string Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
willem
Newbie
Newbie


Joined: 07 April 2009
Online Status: Offline
Posts: 5
Posted: 13 June 2010 at 11:12am | IP Logged Quote willem

Hello, I try to make this htaccess work in ISAPI 2
I want a 301 redirect for every query-string in the site except for mydir where the query-string should work

example : index.php?id=45 to index.php
This is the htaccess :
RewriteCond $1 !mydir/
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.mysite.com/$1? [R=301]

Some help please!!!
Back to Top View willem's Profile Search for other posts by willem
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Online
Posts: 10489
Posted: 14 June 2010 at 5:02am | IP Logged Quote Anton

Firstly, ISAPI_Rewrite v2 operates httpd.ini files not .htaccess.
Secondly, the syntax is different:

[ISAPI_Rewrite]
RewriteRule /(?!mydir/.*)(.*)\?.+ http\://www.mysite.com/$1 [I,RP]

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


Joined: 07 April 2009
Online Status: Offline
Posts: 5
Posted: 14 June 2010 at 6:21am | IP Logged Quote willem

Thanks Anton, this works perfect.

Is there a reason why you write http\://www.mysite.com/$1 instead of /$1 because it seems to do exactly the same.

How do I have to write the first bit if I want to exclude more than one directory, for instance : !dir1|!dir2|!dir3
I tried a few combinations, but it always breaks the rule...
Back to Top View willem's Profile Search for other posts by willem
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Online
Posts: 10489
Posted: 14 June 2010 at 8:05am | IP Logged Quote Anton

"Is there a reason why you write http\://www.mysite.com/$1 instead of /$1 because it seems to do exactly the same."
- the correct syntax for 201 redirect in ISAPI_Rewrite 2 requires fully qualified path.

"How do I have to write the first bit if I want to exclude more than one directory"
- Here's how it should be:

RewriteRule /(?!(?:dir1|dir2|dir3)/.*)(.*)\?.+ http\://www.mysite.com/$1 [I,RP]

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


Joined: 07 April 2009
Online Status: Offline
Posts: 5
Posted: 14 June 2010 at 9:07am | IP Logged Quote willem

Thanks a lot Anton

Cheers,
Willem
Back to Top View willem's Profile Search for other posts by willem
 

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