PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > Rewrite Engine simply not rewriting
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

Rewrite Engine simply not rewriting

Réponse
 
LinkBack Outils de la discussion
Vieux 07/02/2007, 19h46   #1
garey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Rewrite Engine simply not rewriting

Hi -
I am having a frustrating problem with the RewriteEngine. It
simply isn't working. The module is being loaded and I can see it and
my rules in server-info. I am putting my rewrite rules into the
httpd.conf because I am trying to set up a redirection server. Here
are my rules


<IfModule mod_rewrite.c>

RewriteEngine on
#These next two files and their containing directory should be owned
by nobody
RewriteLock "/var/log/httpd/rewrite/lock"
RewriteLog "/var/log/httpd/rewrite/log"
RewriteLogLevel 9

#Now set up a resolver instance
#External resolution; start program once on server start
RewriteMap rslv prg:/home/webdata/nd/noidr_dpg8
#Main lookup; add artificial prefix for subsequent testing
RewriteRule ^/ark:/(28722/.*)$ "_rslv_${rslv:get $1 myGoto}"
#Test: redirect [R] if it looks like a redirect
RewriteRule ^_rslv_([^:]*://.*)$ $1 [R]
#Test: strip prefix; pass through [PT] if intended for us
RewriteRule ^_rslv_(/.*)$ $1 [PT]
#RewriteRule ^_rslv_(/.*)$ http://library11.berkeley.edu/~gmills
#Test: restore value if lookup failed; let come what may
RewriteRule ^_rslv_$ %{REQUEST_URI}

</IfModule>

Now, the external map program works. The only thing that happens
when I try to access my machine with a URL that has '/ark:/28722/*' in
it is that I get a 404. There is nothing in the rewrite log, and in
the access and error logs are entries saying that I attempted and
failed to access a non-existent file.

I am at my wit's end trying to debug this. Does anyone have any
suggestions?

Garey Mills

  Réponse avec citation
Vieux 07/02/2007, 21h12   #2
shimmyshack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

On 7 Feb, 19:46, "garey" <garey.mi...@gmail.com> wrote:
> Hi -
> I am having a frustrating problem with the RewriteEngine. It
> simply isn't working. The module is being loaded and I can see it and
> my rules in server-info. I am putting my rewrite rules into the
> httpd.conf because I am trying to set up a redirection server. Here
> are my rules
>
> <IfModule mod_rewrite.c>
>
> RewriteEngine on
> #These next two files and their containing directory should be owned
> by nobody
> RewriteLock "/var/log/httpd/rewrite/lock"
> RewriteLog "/var/log/httpd/rewrite/log"
> RewriteLogLevel 9
>
> #Now set up a resolver instance
> #External resolution; start program once on server start
> RewriteMap rslv prg:/home/webdata/nd/noidr_dpg8
> #Main lookup; add artificial prefix for subsequent testing
> RewriteRule ^/ark:/(28722/.*)$ "_rslv_${rslv:get $1 myGoto}"
> #Test: redirect [R] if it looks like a redirect
> RewriteRule ^_rslv_([^:]*://.*)$ $1 [R]
> #Test: strip prefix; pass through [PT] if intended for us
> RewriteRule ^_rslv_(/.*)$ $1 [PT]
> #RewriteRule ^_rslv_(/.*)$ http://library11.berkeley.edu/~gmills
> #Test: restore value if lookup failed; let come what may
> RewriteRule ^_rslv_$ %{REQUEST_URI}
>
> </IfModule>
>
> Now, the external map program works. The only thing that happens
> when I try to access my machine with a URL that has '/ark:/28722/*' in
> it is that I get a 404. There is nothing in the rewrite log, and in
> the access and error logs are entries saying that I attempted and
> failed to access a non-existent file.
>
> I am at my wit's end trying to debug this. Does anyone have any
> suggestions?
>
> Garey Mills


you could watch the filesystem access as you request stuff.
(I use filemon while in windows for thorny apache issues like wrong
document root when mass virtual hosting etc..., to can see each access
and the exact paths giving the errors)

  Réponse avec citation
Vieux 07/02/2007, 21h41   #3
garey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

On Feb 7, 1:12 pm, "shimmyshack" <matt.fa...@gmail.com> wrote:
> On 7 Feb, 19:46, "garey" <garey.mi...@gmail.com> wrote:
>
>
>
> > Hi -
> > I am having a frustrating problem with the RewriteEngine. It
> > simply isn't working. The module is being loaded and I can see it and
> > my rules in server-info. I am putting my rewrite rules into the
> > httpd.conf because I am trying to set up a redirection server. Here
> > are my rules

>
> > <IfModule mod_rewrite.c>

>
> > RewriteEngine on
> > #These next two files and their containing directory should be owned
> > by nobody
> > RewriteLock "/var/log/httpd/rewrite/lock"
> > RewriteLog "/var/log/httpd/rewrite/log"
> > RewriteLogLevel 9

>
> > #Now set up a resolver instance
> > #External resolution; start program once on server start
> > RewriteMap rslv prg:/home/webdata/nd/noidr_dpg8
> > #Main lookup; add artificial prefix for subsequent testing
> > RewriteRule ^/ark:/(28722/.*)$ "_rslv_${rslv:get $1 myGoto}"
> > #Test: redirect [R] if it looks like a redirect
> > RewriteRule ^_rslv_([^:]*://.*)$ $1 [R]
> > #Test: strip prefix; pass through [PT] if intended for us
> > RewriteRule ^_rslv_(/.*)$ $1 [PT]
> > #RewriteRule ^_rslv_(/.*)$ http://library11.berkeley.edu/~gmills
> > #Test: restore value if lookup failed; let come what may
> > RewriteRule ^_rslv_$ %{REQUEST_URI}

>
> > </IfModule>

>
> > Now, the external map program works. The only thing that happens
> > when I try to access my machine with a URL that has '/ark:/28722/*' in
> > it is that I get a 404. There is nothing in the rewrite log, and in
> > the access and error logs are entries saying that I attempted and
> > failed to access a non-existent file.

>
> > I am at my wit's end trying to debug this. Does anyone have any
> > suggestions?

>
> > Garey Mills

>
> you could watch the filesystem access as you request stuff.
> (I use filemon while in windows for thorny apache issues like wrong
> document root when mass virtual hosting etc..., to can see each access
> and the exact paths giving the errors)


I fail to see how watching which files open would ; and I don't
have a filemon utility on my Solaris box. There are no errors being
logged that tell me that I can't write to the rewriteLog file. Is
there anything else that you can suggest?

  Réponse avec citation
Vieux 07/02/2007, 22h07   #4
Jim Hayter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

garey wrote:
> I fail to see how watching which files open would ; and I don't
> have a filemon utility on my Solaris box. There are no errors being
> logged that tell me that I can't write to the rewriteLog file. Is
> there anything else that you can suggest?
>


It sounds like you don't have mod_rewrite in the running httpd daemon.
What happens if you remove these lines: "<IfModule mod_rewrite.c>" and
"</IfModule>". If mod_rewrite is not loaded, you should get errors
trying to use this config.

Jim
  Réponse avec citation
Vieux 07/02/2007, 22h24   #5
garey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

On Feb 7, 2:07 pm, Jim Hayter <see.reply...@nowhere.invalid> wrote:
> garey wrote:
> > I fail to see how watching which files open would ; and I don't
> > have a filemon utility on my Solaris box. There are no errors being
> > logged that tell me that I can't write to the rewriteLog file. Is
> > there anything else that you can suggest?

>
> It sounds like you don't have mod_rewrite in the running httpd daemon.
> What happens if you remove these lines: "<IfModule mod_rewrite.c>" and
> "</IfModule>". If mod_rewrite is not loaded, you should get errors
> trying to use this config.
>
> Jim


Jim - even without the tags the server stops and starts fine.

  Réponse avec citation
Vieux 08/02/2007, 09h32   #6
shimmyshack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

On 7 Feb, 22:24, "garey" <garey.mi...@gmail.com> wrote:
> On Feb 7, 2:07 pm, Jim Hayter <see.reply...@nowhere.invalid> wrote:
>
> > garey wrote:
> > > I fail to see how watching which files open would ;


disk access can show more info than error log, sometimes a lot more.

where is the <IfModule mod_rewrite.c> stanza located, I think
RewriteLog "/var/log/httpd/rewrite/log"
RewriteLogLevel 9
should be placed "globally" rather than inside a directory block and
so on - I assume you have got this right though cos you're using the
main httpd.conf and httpd restarts without errors.

By "URL that has '/ark:/28722/*' in"so you mean something like
http://lib.berk.edu/ark:/28722/so_on
the rewrite rule matches wont match URLs like
http://lib.berk.edu/other_path/ark:/28722/so_on

so here I'm assuming you have tested all the cases by hard coding the
rewriterules (replacing the output of the prg with some string), and
verified them.
If they are, it points the finger at the prg, check you arent using
buffered output, giving the right input to the program. The syntax you
use was new to me
"_rslv_${rslv:get $1 myGoto}" rather than
"_rslv_${rslv:$1}"
where you would write the script to imply get and myGoto.



  Réponse avec citation
Vieux 08/02/2007, 10h36   #7
HansH
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

"shimmyshack" <matt.farey@gmail.com> schreef in bericht
news:1170927157.601491.166260@k78g2000cwa.googlegr oups.com...
> On 7 Feb, 22:24, "garey" <garey.mi...@gmail.com> wrote:
>> On Feb 7, 2:07 pm, Jim Hayter <see.reply...@nowhere.invalid> wrote:
>>
>> > garey wrote:
>> > > I fail to see how watching which files open would ;

>
> disk access can show more info than error log, sometimes a lot more.
>
> where is the <IfModule mod_rewrite.c> stanza located, I think
> RewriteLog "/var/log/httpd/rewrite/log"
> RewriteLogLevel 9
> should be placed "globally" rather than inside a directory block and
> so on - I assume you have got this right though cos you're using the
> main httpd.conf and httpd restarts without errors.

Putting it in the relevant vhost container might do the tric

> By "URL that has '/ark:/28722/*' in"so you mean something like
> http://lib.berk.edu/ark:/28722/so_on
> the rewrite rule matches wont match URLs like
> http://lib.berk.edu/other_path/ark:/28722/so_on

If the * above is a shell-style wildcard so_on will match the rewrite too
RewriteRule ^/ark:/(28722/.*)$ "_rslv_${rslv:get $1 myGoto}"

> ... The syntax you use was new to me
> "_rslv_${rslv:get $1 myGoto}"

Get logging going first, then SEE what's thrown to the script.


HansH


  Réponse avec citation
Vieux 08/02/2007, 21h21   #8
garey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

I got logging to work (I think it was an issue of the log file not
being defined in a virtual host), and it appears that the problem is
that the mapper I am defining is not returning anything. I can invoke
the mapper from the command line with the string that is being passed
to it by the rewrite rule and it is mapping correctly, so my question
is this: what is the current working directory when the mapper is
invoked by Apache?

  Réponse avec citation
Vieux 08/02/2007, 22h15   #9
HansH
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Engine simply not rewriting

"garey" <garey.mills@gmail.com> schreef in bericht
news:1170969692.373428.152270@v33g2000cwv.googlegr oups.com...
>I got logging to work (I think it was an issue of the log file not
> being defined in a virtual host), and it appears that the problem is
> that the mapper I am defining is not returning anything. I can invoke
> the mapper from the command line with the string that is being passed
> to it by the rewrite rule and it is mapping correctly, so my question
> is this: what is the current working directory when the mapper is
> invoked by Apache?

Anything from the script's folder, the document root of the virtual or main
server or even the server root ....

This will tell no tails:
use Cwd;
my $cwd = Cwd::cwd();

Assuming your data is in a seperate file in the same folder as the script,
try:
my $cwd = $0; $cwd =~ s{/[^/]+?}{}o;

Given your use of a compound value like in %{prg:a b c}, temporarely change
the script to echo its input and check all 3 elements are returned.

HansH


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h47.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21570 seconds with 17 queries