|
|
|
|
||||||
| alt.apache.configuration Apache web server configuration issues. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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) |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
"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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
"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 |
|
![]() |
| Outils de la discussion | |
|
|