Re: use mod_rewrite to answer a.php?xyz and serve /xyz ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Works like a charm.  Thanks a lot for your help, now I feel like able to do anything with it.

Now I can understand that dry paragraph:

Note: Query String

The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable. You can, however, create URLs in the substitution string, containing a query string part. Simply use a question mark inside the substitution string, to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine a new query string with an old one, use the [QSA] flag.


Best, Randy

On Tue, Jul 15, 2008 at 3:36 AM, Krist van Besien <krist.vanbesien@xxxxxxxxx> wrote:
On Mon, Jul 14, 2008 at 23:07, Randy Grimes <randygrimes15@xxxxxxxxx> 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@xxxxxxxxx
krist@xxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux