Welcome to WebmasterWorld Guest from 54.144.206.214

Forum Moderators: Ocean10000 & incrediBILL & phranque

Complex mod_rewrite problem

any assistance gratefully received

   
3:47 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Question from our software designer:

---

I'm using mod_rewrite to route URLs to a module done as a Location:

LoadModule BoldRetina_module modules/mod_BoldRetina.so

<Location /BoldRetina >
SetHandler mod_boldretina-handler
</Location>

RewriteEngine On

ReWriteLog c:\rewrite.log.txt
ReWriteLogLevel 9

# now the rewriting rules

# Root directory is mapped to ShowUI?UI=Home
# So incoming: www.mydomain.com/ becomes
www.mydomain.com/BoldRetina/ShowUI?UI=Home

RewriteRule ^/$ /BoldRetina/ShowUI\?UI=Home [L]

I don't want this to be a redirect that the browser sees, so I'm not
using R=301

The problem....

In my log file I get:

192.168.0.1 - - [07/Jan/2003:14:55:02 +0000]
[bryan/sid#23bd68][rid#472f30/initial] (2) init rewrite engine with
requested uri /
192.168.0.1 - - [07/Jan/2003:14:55:02 +0000]
[bryan/sid#23bd68][rid#472f30/initial] (3) applying pattern '^/$' to uri
'/'
192.168.0.1 - - [07/Jan/2003:14:55:02 +0000]
[bryan/sid#23bd68][rid#472f30/initial] (2) rewrite / ->
/BoldRetina/ShowUI?UI=Home

# I want it to stop here, but it does two more steps....

192.168.0.1 - - [07/Jan/2003:14:55:02 +0000]
[bryan/sid#23bd68][rid#472f30/initial] (3) split
uri=/BoldRetina/ShowUI?UI=Home -> uri=/BoldRetina/ShowUI, args=UI=Home
192.168.0.1 - - [07/Jan/2003:14:55:02 +0000]
[bryan/sid#23bd68][rid#472f30/initial] (2) local path result:
/BoldRetina/ShowUI

How can I stop it splitting the query string out into the args string?
The module I'm using requires the query string to be part of the URL.

---

Can anyone suggest what we can do to address this issue? Thanks. :)

4:56 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The query string is still there after the rewriting is done.

Given a RewriteRule

RewriteRule /acarter /index.php?para=acarter

and a php script like

<?php echo $_SERVER['QUERY_STRING'];?>

you get

para=acarter

when /acarter is requested. Yet the RewriteLog still shows

init rewrite engine with requested uri /acarter 
applying pattern '/acarter' to uri '/acarter'
rewrite /acarter -> /index.php?para=acarter
split uri=/index.php?para=acarter
-> uri=/index.php, args=para=acarter
local path result: /index.php
prefixed with document_root to /var/www/html/index.php
go-ahead with /var/www/html/index.php [OK]

The splitting is only necessary to continue any matching. If it mod_rewrite did not strip off the query string from the end of the URI then a rule like this would not work:

RewriteRule /index.php$ /do_whatever

Since index.php would end with index.php?para=acarter.

Your module should be able to retrieve the query string from the query field of the uri_components record. This record may be accessed via the parsed_uri field of every incoming request.

Andreas

5:07 pm on Jan 7, 2003 (gmt 0)

10+ Year Member



Hi guys,

I'm John's software designer. The module is written in Delphi, and I don't have the source...

Interestingly, if I specify a 301 redirect, it works ok, although the user's browser sees the internal path. If I don't it doesn't work - I get a 404.

Could this be something to do with the ordering of Apache url flow? In that the module Location isn't being used after mod_rewrite. Should the modules be declared in any particular order?

Bryan

5:24 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] Bryan.

Be sure to read Marcia`s WebmasterWorld Welcome and Guide to the Basics [webmasterworld.com] post.

Could this be something to do with the ordering of Apache url flow? In that the module Location isn't being used after mod_rewrite. Should the modules be declared in any particular order?

Try changing the order of the AddModule (mod_rewrite.c¦your_module) directives in httpd.conf.

Interestingly, if I specify a 301 redirect, it works ok, although the user's browser sees the internal path.

It works since mod_rewrite does not do anything on the second request.

Andreas

5:51 pm on Jan 7, 2003 (gmt 0)

10+ Year Member



Tell a lie, I get a 400 error - Bad Request.

Is there a way to get apache to tell me why it failed?

Bryan

5:57 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The error log?

Set error reporting to the highest possible level.

Andreas

6:07 pm on Jan 7, 2003 (gmt 0)

10+ Year Member



Set the logging level to debug.

All I get is
192.168.0.1 - - [07/Jan/2003:18:06:29 +0000] "GET / HTTP/1.1" 400 290
in the access.log

and nothing at all in the error.log

10:26 am on Jan 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bump - any other input on this gratefully received...
3:59 pm on Jan 10, 2003 (gmt 0)

10+ Year Member



Solved it.

I have to use the [PT] flag as it's being passed on to another module. doh!

Bryan

1:47 am on Jan 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you got it to work Bryan.

I considered suggesting the [PT] flag but then thought that your module probably is a content handler and not another module called from the URI-translation hook.

Andreas

 

Featured Threads

Hot Threads This Week

Hot Threads This Month