You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ifz 77i <if...@googlemail.com> on 2006/01/22 13:46:45 UTC

[users@httpd] Small rewrite problem

I've asked on a few IRC channels with no fix :(

Server version:
Apache/2.0.55

URL:
http://www3/a.php?b=moo

Error:
404 Not Found
The requested URL /a.php was not found on this server.

.htaccess contents:
RewriteEngine On
RewriteRule ^/*a\.php\?b=(.*)$ /b.php?a=$1

log_rewrite contents:
192.168.1.101 - - [17/Jan/2006:08:36:37 +0000]
[www3/sid#8153f68][rid#822f050/initial] (3) [per-dir
/home/mick/sites/www3/htdocs/] strip per-dir prefix:
/home/mick/sites/www3/htdocs/a.php -> a.php
192.168.1.101 - - [17/Jan/2006:08:36:37 +0000]
[www3/sid#8153f68][rid#822f050/initial] (3) [per-dir
/home/mick/sites/www3/htdocs/] applying pattern '^/*a\.php\?b=(.*)$'
to uri 'a.php'
192.168.1.101 - - [17/Jan/2006:08:36:37 +0000]
[www3/sid#8153f68][rid#822f050/initial] (1) [per-dir
/home/mick/sites/www3/htdocs/] pass through
/home/mick/sites/www3/htdocs/a.php

---------------------------------------------------------------------
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] Small rewrite problem

Posted by ifz 77i <if...@googlemail.com>.
> RewriteCond %{QUERY_STRING} ^b=(.*)$
> RewriteRule a\.php /b.php?%1

Thank you Sir, that works perfectly.

---------------------------------------------------------------------
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] Small rewrite problem

Posted by Joshua Slive <jo...@slive.ca>.
On 1/22/06, ifz 77i <if...@googlemail.com> wrote:
> URL:
> http://www3/a.php?b=moo
>
> Error:
> 404 Not Found
> The requested URL /a.php was not found on this server.
>
> .htaccess contents:
> RewriteEngine On
> RewriteRule ^/*a\.php\?b=(.*)$ /b.php?a=$1

>  (3) [per-dir
> /home/mick/sites/www3/htdocs/] applying pattern '^/*a\.php\?b=(.*)$'
> to uri 'a.php'

As this log line shows, and as the docs discuss in a big box marked
"Query String", RewriteRules do not match against the query string. 
You need something more like:

RewriteCond %{QUERY_STRING} ^b=(.*)$
RewriteRule a\.php /b.php?%1

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] Small rewrite problem

Posted by ht...@karsites.net.
This is probably all you need to master regular expression 
syntax. Very brief and concise. Then you need to get your 
head around mod_rewrite:

Title: Regular Expression Pocket Reference
Author: Tony Stubblebine
Publisher: O'reilly
ISBN: 0-596-00415-X
86 pages plus index

US$ 12.95
GBP  7.00

HTH

Keith

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