Converting mod_rewrite rules!

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 5
Joined: 03 Jan 2013, 22:33

Converting mod_rewrite rules!

03 Jan 2013, 22:39

I have some rules given to me from mod_rewrite on Linux, but I cannot seem to even get past the first rule:

Code: Select all
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteCond %{ENV:ENVDOCROOTDIR}/mobile/index.html -f
RewriteRule .* http://mobile.%{ENV:ENVDNAME}/ [R=302,L,NC]


Basically if it's a mobile user agent and /mobile/index.html exists, redirect to mobile.<domain> URL.

Both these rules just give me invalid sting:

Code: Select all
[ISAPI_Rewrite]

RewriteCond User-Agent: android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos
RewriteCond User-Agent: (android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos)


I'm probably doing something very basic wrong here, any ideas?

Thanks,

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

Re: Converting mod_rewrite rules!

04 Jan 2013, 05:38

Hello,

I guess what you do is just edit the conditions, not the rule.
The three lines of original code you provided are a single rule with 2 conditions. The resulting lines represent only the conditions, not the rule.

Sorry if I misunderstood you.

Regards
Andrew

User avatar
Posts: 5
Joined: 03 Jan 2013, 22:33

Re: Converting mod_rewrite rules!

04 Jan 2013, 10:20

I'm trying to edit the conditions but it just gives me invalid string. I can't even get past the conditions and onto the rule.

What I posted was an example of the two conditions I tried, both failed.

I haven't got a complete condition/rule set for this, as I have no idea how to do it! :-)

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

Re: Converting mod_rewrite rules!

04 Jan 2013, 20:23

Please, provide more information: what error do you get? where do you post the rule?
I could be that you simply installed ISAPI_Rewrite 3 and trying to use v2 syntax

Regards
Andrew

User avatar
Posts: 5
Joined: 03 Jan 2013, 22:33

Re: Converting mod_rewrite rules!

09 Jan 2013, 15:00

I decided to cut my loses and install v3 instead (it was definitely v2 being used before), but now a new problem.

Every time I hit the page "httpd.parse.errors" is generated, but it's empty, and I know there are errors in it, because it is thus:

Code: Select all
RewriteEngine On

RewriteLogLevel 9
LogLevel debug

RewriteCond THIS IS DEFINITION AN ERROR IN MY CONFIG (#$&(&$(*#&($*@$


Ideas?

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

Re: Converting mod_rewrite rules!

10 Jan 2013, 16:37

Hm.. httpd.parse.errors is not our file.
I'm afraid the problem is not quite clear. Please, provide the rule, the testing request and the rewrite.log and error.log for the testing request.

Logging issues described in FAQ

Regards
Andrew

User avatar
Posts: 5
Joined: 03 Jan 2013, 22:33

Re: Converting mod_rewrite rules!

14 Jan 2013, 06:29

Hrm, odd, something is creating it, I thought this file was ISAPI Rewrites because of the documentation:

http://www.isapirewrite.com/docs/
... "That will allow creation of httpd.parse.errors files containing config files parsing errors. " ...

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

Re: Converting mod_rewrite rules!

14 Jan 2013, 08:46

This file is meant for ISAPI_Rewrite 2, while you said you installed ISAPI_Rewrite 3. That's the reason I suggested FAQ, which describes the logging issue for ISAPI_Rewrite 3. Note that ISAPI_Rewrite 2 and 3 can not be installed at the same time.

Regards
Andrew

User avatar
Posts: 5
Joined: 03 Jan 2013, 22:33

Re: Converting mod_rewrite rules!

15 Jan 2013, 07:15

Okay, I've got the following in my global htttp.conf :

Code: Select all
#enabling rewrite.log
RewriteLogLevel 9
#enabling error.log
LogLevel debug


It's indicated that loading went correctly, from the global error.log:

Code: Select all
[...] C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf - Loaded successfully
[...] ISAPI Filter loaded. Version 3.1.0.96. Windows 5.2 (Build 3790 ServicePack:2) ProductType SERVER. CPU type INTEL  NumberOfProcessors 4.


There's a local httpd.conf file for a single domain, in its webroot, which still contains:

Code: Select all
RewriteEngine On

RewriteLogLevel 9
LogLevel debug

RewriteCond THIS IS DEFINITION AN ERROR IN MY CONFIG (#$&(&$(*#&($*@$


But no error log is produced there, and nothing is indicated in global.

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

Re: Converting mod_rewrite rules!

15 Jan 2013, 10:03

Hm.... you don't create httpd.conf for a single domain. httpd.conf is a server wide config file. If you want to use site-wide config - .htaccess is right for you.
Please, note the path of your server config file:

C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf - Loaded successfully


Also, please, clarify what is the following:

Code: Select all
RewriteCond THIS IS DEFINITION AN ERROR IN MY CONFIG (#$&(&$(*#&($*@$


regards
Andrew

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 9 guests