urgent help with a rule

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 5
Joined: 16 Aug 2012, 05:10

urgent help with a rule

16 Aug 2012, 05:15

HI

I have this current rule which returns a 404page if there is is anything passed after the .htm.
thw below rule works perfect.

#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.htm[^a-zA-Z].+ http\://xxx.x.com/error/404_test.asp [U,CL,L]

Now i need a exception put into this rule if in .htm pages has a ?gclid= allow rest of the string should return a 404 page as it is doing now.


can you please help me with this rule.

regards
deepak

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: urgent help with a rule

16 Aug 2012, 05:59

Hello, Deepak

Please try it like this:

#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.htm(?!.*gclid=allow.*).+ http\://xxx.x.com/error/404_test.asp [U,CL,L]

User avatar
Posts: 5
Joined: 16 Aug 2012, 05:10

Re: urgent help with a rule

16 Aug 2012, 07:00

HI Anton,

thanks for your reply.The below rule works for what i want but there is a problem.i have .htm and .html pages.once i implemente the below mentioned rule my .html pages stop working.
#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.htm(?!.*gclid=allow.*).+ http\://xxx.x.com/error/404_test.asp [U,CL,L]

can you please help me

thanks
deepak

User avatar
Posts: 5
Joined: 16 Aug 2012, 05:10

Re: urgent help with a rule

16 Aug 2012, 07:01

HI Anton,

thanks for your reply.The below rule works for what i want but there is a problem.i have .htm and .html pages.once i implemente the below mentioned rule my .html pages stop working.

I want the rule to fire only for .htm pages not for the .html pages.

#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.htm(?!.*gclid=allow.*).+ http\://xxx.x.com/error/404_test.asp [U,CL,L]

can you please help me

thanks
deepak

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: urgent help with a rule

16 Aug 2012, 07:19

Hello,

please have this small fix:

#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.html?(?!.*gclid=allow.*).+ http\://xxx.x.com/error/404_test.asp [U,CL,L]

User avatar
Posts: 5
Joined: 16 Aug 2012, 05:10

Re: urgent help with a rule

16 Aug 2012, 07:49

HI Anton,

i think there is a misundestanding.Below mentioned rule works as per i want.But i have filetype in our website which is .html and .htm

i want this rule to fire only for .htm file types.For .html and other file types as asp or aspx i dont want this rule to fire.

IF the below rule it works fine but if i visit a .html file type page then it redirects to a 404 page which i dont want.

As mentioned above i need this rule only to fire for .htm pages.can you please help me

#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.htm(?!.*gclid=allow.*).+ http\://xxx.x.com/error/404_test.asp [U,CL,L]

thanks
deepak

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: urgent help with a rule

16 Aug 2012, 07:54

Sorry, I got it wrong.
Here's the rule which should work for you:

#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.htm(?!.*gclid=allow.*)(\?.+) http\://xxx.x.com/error/404_test.asp [U,CL,L]

User avatar
Posts: 5
Joined: 16 Aug 2012, 05:10

Re: urgent help with a rule

20 Aug 2012, 08:56

HI Anton,

this rule works fine.But i have another rule which rule runs below the above rule.

For now the below mentioned rule has be commented.

The below rule gives a 404 header for the url ending with / .ie. x.x.com/folder/subfolder/filename.htm/ should return a 404 page.

how can i tweak this rule so it works perfectly with the gclid rule.

RewriteCond Host: (?:x\.x\.com.*)
RewriteRule [^?]+?\.htm[/?].* http\://x.x.com/error/404_test.asp [U,CL,L]


regards
deepak

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: urgent help with a rule

20 Aug 2012, 09:19

Hello, Deepak

Please try to have the rules like this:

RewriteCond Host: x\.x\.com.*
RewriteRule .+\.htm/ http\://x.x.com/error/404_test.asp [U,CL,L]

#end of \ slash in the url only for htm pages
RewriteCond Host: (?:xxx\.xxxl\.com.*)
RewriteRule .+\.htm(?!.*gclid=allow.*)(\?.+) http\://xxx.x.com/error/404_test.asp [U,CL,L]

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 9 guests