You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Andrew Hole <an...@gmail.com> on 2009/09/02 12:02:45 UTC

[users@httpd] rewriterule help

Hi guys!

The following directive doesn't take into consideration the filename in URL:
  RewriteCond %{DOCUMENT_ROOT}/bin/core/%1 -f

In this request the REQUEST_FILENAME has the value: /bin/adt/file.swf but I
just want the filename (file.swf).

How can I do that?

Thanks a lot


   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{DOCUMENT_ROOT}/bin/core/%1 -f
   RewriteRule ^(.*)$ /core/$1 [L]

192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
[clappehr/sid#65c800][rid#87e078/initial] (2) init rewrite engine with
requested uri /bin/adt/file.swf
192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
[clappehr/sid#65c800][rid#87e078/initial] (3) applying pattern '^(.*)$' to
uri '/bin/adt/file.swf'
192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
[clappehr/sid#65c800][rid#87e078/initial] (4) RewriteCond:
input='/bin/adt/file.swf' pattern='!-f' => matched
192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
[clappehr/sid#65c800][rid#87e078/initial] (4) RewriteCond:
input='R:/EHR/client/pfh/bin/core/' pattern='-f' => not-matched

Re: [users@httpd] rewriterule help

Posted by Krist van Besien <kr...@gmail.com>.
On Wed, Sep 2, 2009 at 1:15 PM, Andrew Hole<an...@gmail.com> wrote:
> It works. However, i'm getting a popup with file save option and I would
> like to see the page on Browser.

That is probably due to an incorrect content type header. Have a look
at what the server sends with an appropriate tool (Firebug or
HTTPHeaders for Firefox for example...)


Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
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] rewriterule help

Posted by Andrew Hole <an...@gmail.com>.
It works. However, i'm getting a popup with file save option and I would
like to see the page on Browser.

Thanks a lot

On Wed, Sep 2, 2009 at 11:41 AM, Krist van Besien <krist.vanbesien@gmail.com
> wrote:

> On Wed, Sep 2, 2009 at 12:02 PM, Andrew Hole<an...@gmail.com>
> wrote:
> > Hi guys!
> >
> > The following directive doesn't take into consideration the filename in
> URL:
> >   RewriteCond %{DOCUMENT_ROOT}/bin/core/%1 -f
>
>
>
> >    RewriteCond %{REQUEST_FILENAME} !-f
> >    RewriteCond %{DOCUMENT_ROOT}/bin/core/%1 -f
> >    RewriteRule ^(.*)$ /core/$1 [L]
> >
> > 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> > [clappehr/sid#65c800][rid#87e078/initial] (2) init rewrite engine with
> > requested uri /bin/adt/file.swf
> > 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> > [clappehr/sid#65c800][rid#87e078/initial] (3) applying pattern '^(.*)$'
> to
> > uri '/bin/adt/file.swf'
> > 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> > [clappehr/sid#65c800][rid#87e078/initial] (4) RewriteCond:
> > input='/bin/adt/file.swf' pattern='!-f' => matched
> > 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> > [clappehr/sid#65c800][rid#87e078/initial] (4) RewriteCond:
> > input='R:/EHR/client/pfh/bin/core/' pattern='-f' => not-matched
>
> %1 is the result of any capture performed during the matching in the
> RHS of y RewriteCond. If you use it in the LHS it will be empty, as
> you can see in the logs. Which is why this doesn't work.
> You can capture the filename in the RewriteRule, and use that.
>
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{DOCUMENT_ROOT}/bin/core/$2 -f
> RewriteRule ^(.*)/(.*)$ /bin/core/$1/$2 [L]
>
> (I haven't acutally testet this, but this should work...)
>
> Krist
>
>
> --
> krist.vanbesien@gmail.com
> krist@vanbesien.org
> Bremgarten b. Bern, Switzerland
> --
> A: It reverses the normal flow of conversation.
> Q: What's wrong with top-posting?
> A: Top-posting.
> Q: What's the biggest scourge on plain text email discussions?
>
> ---------------------------------------------------------------------
> 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] rewriterule help

Posted by Krist van Besien <kr...@gmail.com>.
On Wed, Sep 2, 2009 at 12:02 PM, Andrew Hole<an...@gmail.com> wrote:
> Hi guys!
>
> The following directive doesn't take into consideration the filename in URL:
>   RewriteCond %{DOCUMENT_ROOT}/bin/core/%1 -f



>    RewriteCond %{REQUEST_FILENAME} !-f
>    RewriteCond %{DOCUMENT_ROOT}/bin/core/%1 -f
>    RewriteRule ^(.*)$ /core/$1 [L]
>
> 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> [clappehr/sid#65c800][rid#87e078/initial] (2) init rewrite engine with
> requested uri /bin/adt/file.swf
> 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> [clappehr/sid#65c800][rid#87e078/initial] (3) applying pattern '^(.*)$' to
> uri '/bin/adt/file.swf'
> 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> [clappehr/sid#65c800][rid#87e078/initial] (4) RewriteCond:
> input='/bin/adt/file.swf' pattern='!-f' => matched
> 192.168.1.167 - - [02/Sep/2009:10:57:34 +0100]
> [clappehr/sid#65c800][rid#87e078/initial] (4) RewriteCond:
> input='R:/EHR/client/pfh/bin/core/' pattern='-f' => not-matched

%1 is the result of any capture performed during the matching in the
RHS of y RewriteCond. If you use it in the LHS it will be empty, as
you can see in the logs. Which is why this doesn't work.
You can capture the filename in the RewriteRule, and use that.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/bin/core/$2 -f
RewriteRule ^(.*)/(.*)$ /bin/core/$1/$2 [L]

(I haven't acutally testet this, but this should work...)

Krist


-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
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