You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Thomas Joseph Olaes <th...@gmail.com> on 2004/08/24 19:57:58 UTC

[users@httpd] mod_rewrite backreference not giving me what I want

Hello list,

I'm having a bit of a problem. I'm trying to use .htaccess to
implement some mod_rewrite rules. Here's what I have:

RewriteEngine on
RewriteBase /test/cb
RewriteRule ^test\.htm$ index.php?t=a$0 [L]
RewriteRule ^(.*)\.(php|html?)$ index.php?t=b$0 [L]

in index.php, I have:

<?php
  echo $t;
  echo "<pre>";
  print_r($_SERVER);
  echo "</pre>";
?>

for pretty much every URL I send to this directory, I always get the
second RewriteRule.

The .htaccess is currently sitting at http://www.mydomain.com/test/cb,
as is the index.php file.

My question is: why is the $0 backreference matching the page that the
path gets rewritten to, instead of the matched regexp string from the
path submitted to the server?

Thanks in advance for any answers and time given to my question.

-TJ

---------------------------------------------------------------------
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 backreference not giving me what I want

Posted by Robert Andersson <ro...@profundis.nu>.
Thomas Joseph Olaes wrote:
> I apologize for reposting this to the mailing list, but I fear that I
> may have slipped through a bunch of mail filters since I didn't put
> [users@httpd] in front of my message.

It came through; that tag is automatically inserted by the list software.

About your problem, I am (and likely others are) not sure about the
behaviour you want of your rewrite rules. Trying to figure out someone
else's regexps, especially when they are claimed not to work, is not easy
business; at least it is too time consuming for most to even bother.

Please do a thourough explaination with examples of URIs you want rewritten
and to what.

Regards,
Robert Andersson


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


[users@httpd] mod_rewrite backreference not giving me what I want

Posted by Thomas Joseph Olaes <th...@gmail.com>.
I apologize for reposting this to the mailing list, but I fear that I
may have slipped through a bunch of mail filters since I didn't put
[users@httpd] in front of my message.

Thanks again for your time.

-TJ


---------- Forwarded message ----------
From: Thomas Joseph Olaes <th...@gmail.com>
Date: Tue, 24 Aug 2004 10:57:58 -0700
Subject: mod_rewrite backreference not giving me what I want
To: users@httpd.apache.org

Hello list,

I'm having a bit of a problem. I'm trying to use .htaccess to
implement some mod_rewrite rules. Here's what I have:

RewriteEngine on
RewriteBase /test/cb
RewriteRule ^test\.htm$ index.php?t=a$0 [L]
RewriteRule ^(.*)\.(php|html?)$ index.php?t=b$0 [L]

in index.php, I have:

<?php
  echo $t;
  echo "<pre>";
  print_r($_SERVER);
  echo "</pre>";
?>

for pretty much every URL I send to this directory, I always get the
second RewriteRule.

The .htaccess is currently sitting at http://www.mydomain.com/test/cb,
as is the index.php file.

My question is: why is the $0 backreference matching the page that the
path gets rewritten to, instead of the matched regexp string from the
path submitted to the server?

Thanks in advance for any answers and time given to my question.

-TJ

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