You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Israel Brewster <is...@frontierflying.com> on 2007/03/07 18:43:14 UTC
[users@httpd] mod_rewrite problem
I am having a very aggravating problem with Rewrite rules, one in
particular. In the root level of my webserver, I have an .htaccess
file that includes (among others) the following lines:
RewriteEngine On
RewriteBase /
RewriteRule ^nagios[/A-Za-z0-9]* index.php?/categories/8-Nagios
[NC,QSA,L]
there are about a dozen additional RewriteRules following that one,
but they all work properly. This one, however, does not appear to-the
URL gets re-written to something (since otherwise I'd just get a 404
error- /nagios does not exist at all on my webserver), but instead of
ending up where I want to, I end up at the main index page (index.php
rather than index.php?/categories/8-Nagios). What I know:
1) The rewrite portion of the rule is correct. If I copy and paste
the URL into my browser, I end up at the proper page
2) The match is happening on that rule, not one of the following
ones. If I change the rewrite portion to something not on my
webserver, I get a 404 error as would be expected. Same thing if I
remove the rewrite rule entirely.
3) If I add the R flag to the rule, the proper page loads, BUT it
changes the URL in the address bar to index.php?/... which I don't
want. Leaving out the R flag doesn't change the URL in the address
bar, but as already mentioned, I end up in the wrong place
4) This Could be caused by the portion of the url after the
index.php? being wrong- index.php?/RandomText will end up with the
main home page rather than an error. This does not appear to be what
is happening, however- see below.
Looking at the rewrite log shows the following entries:
xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
sid#1802648][rid#1838c38/initial] (2) init rewrite engine with
requested uri /nagios
xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
sid#1802648][rid#1838c38/initial] (1) pass through /nagios
xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
sid#1802648][rid#1838c38/initial] (2) [per-dir /WebServer/Documents/]
rewrite nagios -> index.php?/categories/8-Nagios
xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
sid#1802648][rid#1838c38/initial] (2) [per-dir /WebServer/Documents/]
trying to replace prefix /WebServer/Documents/ with /
xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
sid#1802648][rid#1838c38/initial] (1) [per-dir /WebServer/Documents/]
internal redirect with /index.php [INTERNAL REDIRECT]
this would seem to indicate that the rewrite IS happening, and
correctly-the third entry shows nagios being replaced with the proper
index.php string. Those entries, however, are immediately followed by
the normal string of entries for loading the index page. The
http_access log for the same time, shows the following entry:
12.18.177.155 - - [07/Mar/2007:08:28:05 -0900] "GET /nagios HTTP/1.1"
404 12899
followed, again, by a normal load of the index page. This would seem
to indicate that the URL IS NOT being rewriten, but if that was the
case I should get a 404 error page, not the index page (as I do if I
comment out the rewrite rule entirely). So, anyone have any idea what
is going on here, and what I can do to fix it? I have been over the
rewrite docs forward and backward, and I can't find anything that
would indicate what the issue is- as far as I can tell, I have
everything set up properly. I am running Apache 1.3.33 under Mac OS X
10.4.8 Thanks!
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by matt farey <ma...@gmail.com>.
Israel Brewster wrote:
> On Mar 8, 2007, at 8:33 AM, matt farey wrote:
>
>> yeah, if you compare the number and type of rewrites for this package
>> with the way that wordpress used to operate, there is a lot of
>> correlation, instead now wordpress uses a much simpler form of rewrite
>> which directs the REQUEST_URI to the application for subsequent
>> alteration, as is the case with your serendipity app. My idea would be
>> to handle all the serendipity rules with the app, leaving a much smaller
>> set of rules which would happily coexist and be easy to modify. I know
>> you say you aren't a php developer, but it wouldn't be that hard to
>> locate and alter the script, perhaps though it would be difficult to
>> subsequently update Serendipity and you would feel this would be a step
>> too far. my $0.02 - when wordpress changed their rewrite rules from 2k
>> down to 4 lines it was great!
>
> Actually, after the behavior I've been seeing while trying to work out
> this issue, I think the serendipity application may already work this
> way, in spite of the fact that it writes out that long list of rules.
> If I am understanding what is going on properly, then as long as the
> REQUEST_URI typed into the address bar is one that serendipity
> understands (i.e. /categories/8-Nagios) then it doesn't really matter
> what it is rewritten to, as long as the rewrite calls index.php? So,
> in theory at least, I should be able to replace all those rewrites
> with a blanket rewrite whatever to index.php?url=, and it should still
> work. Of course, I would need to have exceptions for the things I
> DON'T want handled my the serendipity php script, but that shouldn't
> be too difficult. I'll have to experiment with that some.
>
>
I am sure you are right, it's why I mentioned it really, here's the rule
that I swear by - not that I swear really!
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,NS]
obviously placed in some directory statement in the main
httpd-rewrites.conf file.
Using a couple of extra conditions might be all you need to prevent S
from stealing focus as it were, and will lead yuo on to a nice relaxing
weekend.
ciao, m
--
Matthew Farey9
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Israel Brewster <is...@frontierflying.com>.
On Mar 8, 2007, at 8:33 AM, matt farey wrote:
> yeah, if you compare the number and type of rewrites for this package
> with the way that wordpress used to operate, there is a lot of
> correlation, instead now wordpress uses a much simpler form of rewrite
> which directs the REQUEST_URI to the application for subsequent
> alteration, as is the case with your serendipity app. My idea would be
> to handle all the serendipity rules with the app, leaving a much
> smaller
> set of rules which would happily coexist and be easy to modify. I know
> you say you aren't a php developer, but it wouldn't be that hard to
> locate and alter the script, perhaps though it would be difficult to
> subsequently update Serendipity and you would feel this would be a
> step
> too far. my $0.02 - when wordpress changed their rewrite rules from 2k
> down to 4 lines it was great!
Actually, after the behavior I've been seeing while trying to work
out this issue, I think the serendipity application may already work
this way, in spite of the fact that it writes out that long list of
rules. If I am understanding what is going on properly, then as long
as the REQUEST_URI typed into the address bar is one that serendipity
understands (i.e. /categories/8-Nagios) then it doesn't really matter
what it is rewritten to, as long as the rewrite calls index.php? So,
in theory at least, I should be able to replace all those rewrites
with a blanket rewrite whatever to index.php?url=, and it should
still work. Of course, I would need to have exceptions for the
things I DON'T want handled my the serendipity php script, but that
shouldn't be too difficult. I'll have to experiment with that some.
>
> --
> Matthew Farey
>
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by matt farey <ma...@gmail.com>.
Israel Brewster wrote:
> Just got a response from the developer of the PHP script
> (serendipity). Turns out the problem lies there, and not with the
> rewrite rule. Apparently what's going on is that the php script uses
> the REQUEST_URI to determine what to display. If it doesn't recognize
> the REQUEST_URI (as is the case with /nagios) it just displays the
> main page. It would appear that while mod_rewrite successfully
> rewrites the URL and calls the PHP script, it doesn't actually change
> the REQUEST_URI, so the script is still acting on /nagios, which it
> doesn't recognize. I'll admit this is somewhat beyond me at the
> moment, perhaps I need to look more into the difference between the
> REQUEST_URI that the php script is seeing and what, exactly,
> mod_rewrite is changing. At any rate, that at least explains the problem.
>
yeah, if you compare the number and type of rewrites for this package
with the way that wordpress used to operate, there is a lot of
correlation, instead now wordpress uses a much simpler form of rewrite
which directs the REQUEST_URI to the application for subsequent
alteration, as is the case with your serendipity app. My idea would be
to handle all the serendipity rules with the app, leaving a much smaller
set of rules which would happily coexist and be easy to modify. I know
you say you aren't a php developer, but it wouldn't be that hard to
locate and alter the script, perhaps though it would be difficult to
subsequently update Serendipity and you would feel this would be a step
too far. my $0.02 - when wordpress changed their rewrite rules from 2k
down to 4 lines it was great!
--
Matthew Farey
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Israel Brewster <is...@frontierflying.com>.
Just got a response from the developer of the PHP script
(serendipity). Turns out the problem lies there, and not with the
rewrite rule. Apparently what's going on is that the php script uses
the REQUEST_URI to determine what to display. If it doesn't recognize
the REQUEST_URI (as is the case with /nagios) it just displays the
main page. It would appear that while mod_rewrite successfully
rewrites the URL and calls the PHP script, it doesn't actually change
the REQUEST_URI, so the script is still acting on /nagios, which it
doesn't recognize. I'll admit this is somewhat beyond me at the
moment, perhaps I need to look more into the difference between the
REQUEST_URI that the php script is seeing and what, exactly,
mod_rewrite is changing. At any rate, that at least explains the
problem.
On Mar 7, 2007, at 3:38 PM, Vincent Bray wrote:
> [snip]
> What's also changed and also puzzling is there's now two steps where
> there was just one.
>
yeah, sorry. That was one of the things I was experimenting with.
Since I knew the later rewrite rule worked as intended, I thought I'd
try just rewriting /nagios into what the second rule was designed to
match. Kind of a kludgy grasping at straws solution that didn't help
anyway. The line that I am actually running is back with the
index.php? section, I just copied and pasted the wrong code block.
>
>> [snip]
>
> However, the first [L] should cause the second rule to not be reached,
> assuming that the [R] isn't meant to be there as you pointed out in
> the OP.
>
> ... And the last three rules shouldn't do anything (but let's let
> that drop).
Interesting point. However, as these rules were added by serendipity
and not me, and don't affect anything anyway, I'm not too concerned :)
> [snip]
>
> This looks like a general case of mod_rewrite overuse. It's often a
> better idea to use a blanket rewrite with exceptions for static files
> and then let the application split the url from the environment. But
> that's not your problem :)
>
yep :) Actually, the original rule set did have a blanket
anything.html => index.php?url=$1 rule, but as that made it so I
couldn't access the non-serendipity directories on my server (trying,
for example, http://izzy.homeip.net/Alaska/Alaska.html, which is an
actual page, just wound up back at the home page), I removed it.
Thinking about it though, a more elegant solution might be to put
that rewrite rule back in by itself, and then use a RewriteEngine Off
directive in my other directories to override it, or some such
solution. It bears consideration.
>> [snip]
>
> Just an aside, don't mix relative and absolute Options. That directive
> does what you probably think it should but it wouldn't if -Indexes
> weren't the first argument and besides:
> Options FollowSymLinks MultiViews
> has the same effect and requires less typing.
well, it WOULD have the same effect, but for some reason Options
Indexes is the default for the / directory, so if I don't override it
for my other directories it generates an index page if you request a
directory without an index file, which I don't want. I suppose a
better option would be to simply remove the Options Indexes from the
root level Directory block :)
>
>> [snip]
>
> Hrmph, I don't seem to be really helping much. About the script, php
> is a pretty brute-force and ignorance kind of environment so just
> adding:
> phpinfo(); die();
> to the start of the script after the opening <?php tag will show you
> what's getting passed in, just in case the problem is with the app.
which does appear to be the case, as per the developer response.
Thanks for the thoughts!
>
> --
> noodl
> PS. I'm about to pass out for a few hours, good luck : )
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Vincent Bray <no...@gmail.com>.
On 08/03/07, Israel Brewster <is...@frontierflying.com> wrote:
> Oh, sure. Sorry- not trying to make things difficult here, it's just
> that I spent several hours yesterday working on the issue, so I'm a
> bit frustrated, and quite possibly not thinking straight any more :P.
> Anyway, the rewrite rules I'm currently working with are as follows:
So far you've moved your initial config:
RewriteEngine On
RewriteBase /
RewriteRule ^nagios[/A-Za-z0-9]* index.php?/categories/8-Nagios [NC,QSA,L]
from a htaccess file to httpd.conf. Was this stuff alone there, with
these other parts in the httpd.conf file, or were they together?
What's also changed and also puzzling is there's now two steps where
there was just one.
> RewriteLog "/var/log/httpd/rewrite.log"
> RewriteLogLevel 2
### here:
> RewriteRule ^/nagios[/A-Za-z0-9]* /categories/8-Nagios [NC,QSA,L,R]
> RewriteRule ^(/archives/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html) /
> index.php?/$1 [NC,L,QSA]
> RewriteRule ^(/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) /index.php?/
> $1 [NC,L,QSA]
> RewriteRule ^(/feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+
> \.rss) /index.php?/$1 [NC,L,QSA]
> RewriteRule ^(/feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) /
> index.php?/$1 [NC,L,QSA]
### and then here:
> RewriteRule ^(/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) /
> index.php?/$1 [NC,L,QSA]
> RewriteRule ^/archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/
> $1.html [NC,L,QSA]
> RewriteRule ^(/[0-9]+)[_\-][0-9a-z_\-]*\.html /index.php?url=$1-
> article.html [L,NC,QSA]
> RewriteRule ^/feeds/(.*) /index.php?url=/feeds/$1 [L,QSA]
> RewriteRule ^/unsubscribe/(.*)/([0-9]+) /index.php?url=/unsubscribe/
> $1/$2 [L,QSA]
> RewriteRule ^/approve/(.*)/(.*)/([0-9]+) /index.php?url=approve/$1/$2/
> $3 [L,QSA]
> RewriteRule ^/delete/(.*)/(.*)/([0-9]+) /index.php?url=delete/$1/$2/
> $3 [L,QSA]
> RewriteRule ^(/admin|entries)(/.+)? /index.php?url=admin/ [L,QSA]
> RewriteRule ^/archive/? /index.php?url=/archive [L,QSA]
> RewriteRule ^(/index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) /
> rss.php?file=$1&ext=$2
> RewriteRule ^(/plugin|plugin)/(.*) /index.php?url=$1/$2 [L,QSA]
> RewriteRule ^/search/(.*) /index.php?url=/search/$1 [L,QSA]
> RewriteRule ^/comments/(.*) /index.php?url=/comments/$1 [L,QSA]
> RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/
> $1 [L,QSA]
> RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA]
> RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
However, the first [L] should cause the second rule to not be reached,
assuming that the [R] isn't meant to be there as you pointed out in
the OP.
... And the last three rules shouldn't do anything (but let's let that drop).
> Aside from the nagios one that I added, this is the standard set of
> rules for a serendipity (www.s9y.org) install. I have tried
> commenting out all of them (completely breaking my site, of course)
> except for the nagios one, but I still wind up at the index page when
> I try accessing /nagios. The Directory block for the root directory
> (which this is all running out of) is the following:
This looks like a general case of mod_rewrite overuse. It's often a
better idea to use a blanket rewrite with exceptions for static files
and then let the application split the url from the environment. But
that's not your problem :)
> <Directory "/WebServer/Documents">
> Options -Indexes FollowSymLinks MultiViews
> AllowOverride All
> Order allow,deny
> Allow from all
> RewriteEngine On
> </Directory>
Just an aside, don't mix relative and absolute Options. That directive
does what you probably think it should but it wouldn't if -Indexes
weren't the first argument and besides:
Options FollowSymLinks MultiViews
has the same effect and requires less typing.
> the rest of my httpd.conf is default, the only other parts I have
> edited being the server name and UseCanonicalName directives.
>
> I could potentially edit the php file, but I really don't know php-
> my programing skills are primarily limited to shell scripting and C+
> + :) Where would I stick that code, or would that depend on the
> script (as I suspect would be the case)? It is the serendipity
> index.php file if you want to download it and take a look. Thank you
> VERY much for your help. I greatly appreciate it :)
Hrmph, I don't seem to be really helping much. About the script, php
is a pretty brute-force and ignorance kind of environment so just
adding:
phpinfo(); die();
to the start of the script after the opening <?php tag will show you
what's getting passed in, just in case the problem is with the app.
--
noodl
PS. I'm about to pass out for a few hours, good luck : )
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Israel Brewster <is...@frontierflying.com>.
On Mar 7, 2007, at 1:16 PM, Vincent Bray wrote:
> Like, posting the rest of your rules, perhaps? As you're rewriting to
> a php script, are you able to edit it to show a dump of the
> environment? phpinfo(); die(); does that job.
> Also, are there any Alias directives for nagios? Seeing your config in
> more detail would help.
> --
> noodl
Oh, sure. Sorry- not trying to make things difficult here, it's just
that I spent several hours yesterday working on the issue, so I'm a
bit frustrated, and quite possibly not thinking straight any more :P.
Anyway, the rewrite rules I'm currently working with are as follows:
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 2
RewriteRule ^/nagios[/A-Za-z0-9]* /categories/8-Nagios [NC,QSA,L,R]
RewriteRule ^(/archives/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html) /
index.php?/$1 [NC,L,QSA]
RewriteRule ^(/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) /index.php?/
$1 [NC,L,QSA]
RewriteRule ^(/feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+
\.rss) /index.php?/$1 [NC,L,QSA]
RewriteRule ^(/feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) /
index.php?/$1 [NC,L,QSA]
RewriteRule ^(/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) /
index.php?/$1 [NC,L,QSA]
RewriteRule ^/archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/
$1.html [NC,L,QSA]
RewriteRule ^(/[0-9]+)[_\-][0-9a-z_\-]*\.html /index.php?url=$1-
article.html [L,NC,QSA]
RewriteRule ^/feeds/(.*) /index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^/unsubscribe/(.*)/([0-9]+) /index.php?url=/unsubscribe/
$1/$2 [L,QSA]
RewriteRule ^/approve/(.*)/(.*)/([0-9]+) /index.php?url=approve/$1/$2/
$3 [L,QSA]
RewriteRule ^/delete/(.*)/(.*)/([0-9]+) /index.php?url=delete/$1/$2/
$3 [L,QSA]
RewriteRule ^(/admin|entries)(/.+)? /index.php?url=admin/ [L,QSA]
RewriteRule ^/archive/? /index.php?url=/archive [L,QSA]
RewriteRule ^(/index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) /
rss.php?file=$1&ext=$2
RewriteRule ^(/plugin|plugin)/(.*) /index.php?url=$1/$2 [L,QSA]
RewriteRule ^/search/(.*) /index.php?url=/search/$1 [L,QSA]
RewriteRule ^/comments/(.*) /index.php?url=/comments/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/
$1 [L,QSA]
RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
Aside from the nagios one that I added, this is the standard set of
rules for a serendipity (www.s9y.org) install. I have tried
commenting out all of them (completely breaking my site, of course)
except for the nagios one, but I still wind up at the index page when
I try accessing /nagios. The Directory block for the root directory
(which this is all running out of) is the following:
<Directory "/WebServer/Documents">
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
RewriteEngine On
</Directory>
the rest of my httpd.conf is default, the only other parts I have
edited being the server name and UseCanonicalName directives.
I could potentially edit the php file, but I really don't know php-
my programing skills are primarily limited to shell scripting and C+
+ :) Where would I stick that code, or would that depend on the
script (as I suspect would be the case)? It is the serendipity
index.php file if you want to download it and take a look. Thank you
VERY much for your help. I greatly appreciate it :)
> -----------------------------------------------
> Israel Brewster
> Computer Support Technician
> Frontier Flying Service Inc.
> 5245 Airport Industrial Rd
> Fairbanks, AK 99709
> (907) 450-7250 x293
> -----------------------------------------------
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Vincent Bray <no...@gmail.com>.
On 08/03/07, Israel Brewster <is...@frontierflying.com> wrote:
> Ok, yeah- that made the rewrite rules start matching when in the
> httpd.conf file, unfortunately the behavior I'm getting with that
> particular rule is the same. Maybe it's time to consider a different
> approach entirely.
Like, posting the rest of your rules, perhaps? As you're rewriting to
a php script, are you able to edit it to show a dump of the
environment? phpinfo(); die(); does that job.
Also, are there any Alias directives for nagios? Seeing your config in
more detail would help.
--
noodl
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Israel Brewster <is...@frontierflying.com>.
> [snip] In this case, ^nagios never
> matches because the per-directory prefix isn't stripped. ^/nagios is
> what you need, in addition to simillar changes for the rest of your
> rules.
Ok, yeah- that made the rewrite rules start matching when in the
httpd.conf file, unfortunately the behavior I'm getting with that
particular rule is the same. Maybe it's time to consider a different
approach entirely.
> This annoyance aside, putting rewrite rules in server context has
> other advantages, mainly increased speed (regexen are compiled once at
> startup and the uri->filepath translation stage can be skipped) but
> also decreased confusion; rewrite in htaccess involves extra steps
> beyond what seems reasonable to figure out the resulting url.
>
>
> --
> noodl
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Vincent Bray <no...@gmail.com>.
On 08/03/07, Israel Brewster <is...@frontierflying.com> wrote:
> Thanks for your response and suggestions.
>
> On Mar 7, 2007, at 9:48 AM, Vincent Bray wrote:
>
> > Hi, welcome to rewrite-in-htaccess pain and suffering. As you're able
> > to use RewriteLog, why put rewrite rules in htaccess?
>
> When I tried that my RewriteRules stopped working entirely :P I
> suspect that was just a mis-configuration on my part, however, so
> I'll keep looking.
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule in
the note 'per directory Rewrites' is important when moving rewrite
rules from .htaccess files or <Directory> blocks, to per-server
(VirtualHost, or main server) contexts. In this case, ^nagios never
matches because the per-directory prefix isn't stripped. ^/nagios is
what you need, in addition to simillar changes for the rest of your
rules.
This annoyance aside, putting rewrite rules in server context has
other advantages, mainly increased speed (regexen are compiled once at
startup and the uri->filepath translation stage can be skipped) but
also decreased confusion; rewrite in htaccess involves extra steps
beyond what seems reasonable to figure out the resulting url.
--
noodl
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Israel Brewster <is...@frontierflying.com>.
Thanks for your response and suggestions.
On Mar 7, 2007, at 9:48 AM, Vincent Bray wrote:
> Hi, welcome to rewrite-in-htaccess pain and suffering. As you're able
> to use RewriteLog, why put rewrite rules in htaccess?
When I tried that my RewriteRules stopped working entirely :P I
suspect that was just a mis-configuration on my part, however, so
I'll keep looking.
> [snip]
>
> Otherwise (as suggested by rbowen) try adding PT to your flags to
> mitigate RewriteBase confusion.
>
That didn't help
>
> --
> noodl
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite problem
Posted by Vincent Bray <no...@gmail.com>.
On 08/03/07, Israel Brewster <is...@frontierflying.com> wrote:
> Looking at the rewrite log shows the following entries:
>
> xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
> sid#1802648][rid#1838c38/initial] (2) init rewrite engine with
> requested uri /nagios
> xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
> sid#1802648][rid#1838c38/initial] (1) pass through /nagios
> xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
> sid#1802648][rid#1838c38/initial] (2) [per-dir /WebServer/Documents/]
> rewrite nagios -> index.php?/categories/8-Nagios
> xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
> sid#1802648][rid#1838c38/initial] (2) [per-dir /WebServer/Documents/]
> trying to replace prefix /WebServer/Documents/ with /
> xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/
> sid#1802648][rid#1838c38/initial] (1) [per-dir /WebServer/Documents/]
> internal redirect with /index.php [INTERNAL REDIRECT]
Hi, welcome to rewrite-in-htaccess pain and suffering. As you're able
to use RewriteLog, why put rewrite rules in htaccess? I expect this
error will go away if you do because..
It would appear that your rule is having the desired effect of rewriting
http://example.com/nagios
to
http://example.com/index.php?/categories/8-Nagios
however, don't count on [L] stopping the rest of your rules from
running. Because this is in a htaccess file, a subrequest is used to
figure out if rewriting is done yet. I'm not exactly sure why, and I
could be totally wrong, but see what your complete ruleset would do
with the original request.
Otherwise (as suggested by rbowen) try adding PT to your flags to
mitigate RewriteBase confusion.
--
noodl
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org