httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Krist van Besien" <krist.vanbes...@gmail.com>
Subject Re: [users@httpd] use mod_rewrite to answer a.php?xyz and serve /xyz ?
Date Tue, 15 Jul 2008 07:36:15 GMT
On Mon, Jul 14, 2008 at 23:07, Randy Grimes <randygrimes15@gmail.com> wrote:
> Hi, I know mod_rewrite can answer web request to /xyz and internally serving
> a.php?xyz .  However, is it possible to answer a.php?xyz and internally
> serving /xyz , without writing a script a.php?  For the curious minds, we
> are moving from dynamic scripts to pre-generated static pages, and want to
> maintain old links to outside.

You can do this. Know though that the RewriteRule only works on the
URL, and ignores the query string. You can use the query string in
RewriteCond lines though.

So you could use something like this:

RewriteCond %{QUERY_STRING}       ^(.+)$
RewriteRule  /a.php    %1

Basically what this rule does is chekc if the url matches a.php and if
it does then it checks if the QUERY_STRING is at least on charachter
long, capturing it in the process. If that is the case the URL is
replaced with the captured query.

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


Mime
View raw message