Issues with converted rule from 2.0 to 3.0

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 26 Apr 2013, 13:58

Issues with converted rule from 2.0 to 3.0

26 Apr 2013, 17:32

Hi

I am facing issue while trying to run with a rule.
I wanted to convert first argument as folder name and remove rest of the stuff.
For example, below URL from first line should rewrite second line URL:
http://www.domain.com/cart/page-name.asp?first-argument=some-value
http://www.domain.com/some-value/

I tried with below mentioned rule which was converted from older version to match with 3.0 using ISAPI_Rewrite Manager:
RewriteRule ^/([^/]+)/$ /cart/page-name.asp\?first-argument=$1 [NC,L]
RewriteRule ^/cart/page-name.asp\?first-argument=([^/]+)$ http\://www.domain.com/$1/ [NC,R=302]

This is not working for me. Rather it is close to produce desired results but appending query string to desired result which does not exists and results in to page not found error message.
Please advice.

It will be highly appreciated if you can additionally specify one line rule used with 3.0 along with correction to above rule.
Thanks.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Issues with converted rule from 2.0 to 3.0

26 Apr 2013, 18:18

Hello,

Please, try using:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/]+)/$ /cart/page-name.asp\?first-argument=$1 [NC,L]

RewriteCond %{QUERY_STRING} ^first-argument=([^&]+)$ [NC]
RewriteRule ^cart/page-name\.asp$ http://www.domain.com/%1/? [NC,R=302,L]


Regards
Andrew

User avatar
Posts: 3
Joined: 26 Apr 2013, 13:58

Re: Issues with converted rule from 2.0 to 3.0

27 Apr 2013, 08:03

Hi Andrew,

Unfortunately nothing worked for me even after trying possible permutations and combination.

Please find below all data written in .htaccess, form this first couple of things are working fine for me via rules for home page and few hard-coded rules as well. But as i go in depth to convert URLs for dynamic inputs, it got simply failed.
This may be because of my inability to write rules or knowledge. The fact is that, I got good exposure to ISAPI_Rewrite 2.X version and i used it for almost 4 years in my previous organization till 2008 and not afterward.

Code: Select all
RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
RewriteBase
# Unsupported directive: [ISAPI_Rewrite]

# 3600 = 1 hour
# Unsupported directive: CacheClockRate 3600

# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule ^/httpd(?:\.ini|\.parse\.errors).*$ / [NC,F,O]
#  Block external access to the Helper ISAPI Extension
RewriteRule ^.*\.isrwhlp$ / [NC,F,O]
# #########################################################################################################################################
#  For Home page
RewriteCond %{HTTP:Host} ^mydomain\.co.uk$
RewriteRule (.*) http\://www.mydomain.co.uk$1 [NC,R=301]
RewriteRule ^/$ /default.asp [NC,L]
RewriteRule ^/default.asp$ http\://www.mydomain.co.uk/ [NC,R=302]

# Few hard-coded URLs
RewriteRule ^/contact-us/$ /html/contact-us.asp [NC,L]
RewriteRule ^/html/contact-us.asp$ http\://www.mydomain.co.uk/contact-us/ [NC,R=302]
RewriteRule ^/my-basket/$ /cart/my-basket.asp [NC,L]
RewriteRule ^/cart/my-basket.asp$ http\://www.mydomain.co.uk/my-basket/ [NC,R=302]
RewriteRule ^/thank-you/$ /cart/thank-you.asp [NC,L]
RewriteRule ^/cart/thank-you.asp$ http\://www.mydomain.co.uk/thank-you/ [NC,R=302]

# For frame categories page and its paging
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/]+)/$ /cart/page-one.asp\?argument-one=$1 [NC,L]
RewriteCond %{QUERY_STRING} ^argument-one=([^&]+)$ [NC]
RewriteRule ^cart/page-one\.asp$ http://www.mydomain.co.uk/%1/? [NC,R=302,L]

# For frame details page and other related optional elements
RewriteRule ^/([^/]+)/([^/]+)/ /cart/page-two.asp\?argument-one=$1&argument-two=$2 [NC,L]
RewriteRule ^/([^/]+)/([^/]+)/([^/]+)/ /cart/page-three.asp\?argument-one=$1&argument-two=$2&argument-three=$3 [NC,L]
RewriteRule ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/ /cart/page-four.asp\?argument-one=$1&argument-two=$2&argument-three=$3&argument-four=$4 [NC,L]
# #########################################################################################################################################
<Helicon>
ProxySuppressErrors Off
</Helicon>


Please help me to correct rules.
Thanks.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Issues with converted rule from 2.0 to 3.0

28 Apr 2013, 14:42

Hello,

you didn't mention RewriteCpmpatibilty directive and also you did not use "RewriteBase /".
In your case to fix that I'd try to add '/' in front of the pattern in the left part of the rules, as in the following:

Code: Select all
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^/([^/]+)/$ /cart/page-name.asp\?first-argument=$1 [NC,L]

RewriteCond %{QUERY_STRING} ^first-argument=([^&]+)$ [NC]
RewriteRule ^/cart/page-name\.asp$ http://www.domain.com/%1/? [NC,R=302,L]


Regards
Andrew

User avatar
Posts: 3
Joined: 26 Apr 2013, 13:58

Re: Issues with converted rule from 2.0 to 3.0

29 Apr 2013, 17:12

I am bit confused where to use what.
Can you please add efforts to correct file.
This will definitely help me and my team members to do better next time.
Please correct where we went wrong.
Thanks in advance for efforts and help as well.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Issues with converted rule from 2.0 to 3.0

30 Apr 2013, 13:34

In order to correct the whole file and translate v2 syntax into v3 syntax you need to request paid Premium Support. It's a complex issue.
From my side I just sent you a corrected version of the rules that should work now. Their location of the rules in your config file is correct.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 16 guests