You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Dan Goodes <da...@planetmirror.com> on 2004/08/30 06:25:36 UTC

[users@httpd] mod_rewrite and RewriteRule

Hi folks,

Just wondering if someone can tell me what is matched when RewriteRule
does it's work:

i.e.

RewriteRule Pattern Substitution

What string is used as "Pattern"? I always thought it was the path of the
URL, but recent testing seems to indicate that it's the filesystem path
that's matched.

E.g. if I have

RewriteCond %{REQUEST_FILENAME}  -f
RewriteRule ^/(.*)$	/some/script.php?x=$1 [PT,T=application/x-httpd-php,L]

And script.php just echo's $x, then I get the FULL path to the file, not
the matched URL.

Any ideas?

Regards,

Dan Goodes  :  Systems Programmer  :  dang@planetmirror.com

Help support PlanetMirror - Australia's largest Internet archive
by signing up for PlanetMirror Premium : http://planetmirror.com


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

Posted by Joshua Slive <js...@gmail.com>.
On Tue, 31 Aug 2004 09:43:45 -0400, Joshua Slive <js...@gmail.com> wrote:
> On Mon, 30 Aug 2004 14:25:36 +1000 (EST), Dan Goodes
> <da...@planetmirror.com> wrote:
> > What string is used as "Pattern"? I always thought it was the path of the
> > URL, but recent testing seems to indicate that it's the filesystem path
> > that's matched.
> >
> > E.g. if I have
> >
> > RewriteCond %{REQUEST_FILENAME}  -f
> > RewriteRule ^/(.*)$     /some/script.php?x=$1 [PT,T=application/x-httpd-php,L]
> >
> > And script.php just echo's $x, then I get the FULL path to the file, not
> > the matched URL.
> 
> It should be the url-path and not the file-path.  Do you have other
> RewriteRules that might be modifying the url?  Have you tried the
> RewriteLog?

Incidentally, I just discovered that this may not be true.  I always
try to use mod_rewrite in the main server context (outside any
<directory>/<Location>/etc sections).  In this case, you get the
url-path.  If you use it inside other sections, you need to fool
around with stuff like RewriteBase to get the right effect.

Joshua.

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

Posted by Joshua Slive <js...@gmail.com>.
On Mon, 30 Aug 2004 14:25:36 +1000 (EST), Dan Goodes
<da...@planetmirror.com> wrote:
> What string is used as "Pattern"? I always thought it was the path of the
> URL, but recent testing seems to indicate that it's the filesystem path
> that's matched.
> 
> E.g. if I have
> 
> RewriteCond %{REQUEST_FILENAME}  -f
> RewriteRule ^/(.*)$     /some/script.php?x=$1 [PT,T=application/x-httpd-php,L]
> 
> And script.php just echo's $x, then I get the FULL path to the file, not
> the matched URL.

It should be the url-path and not the file-path.  Do you have other
RewriteRules that might be modifying the url?  Have you tried the
RewriteLog?

Joshua.

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