httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noah <>
Subject Re: [users@httpd] Rewriting all URLs to /index.php
Date Wed, 30 Mar 2005 06:29:47 GMT
On Wed, Mar 30, 2005 at 09:58:36AM +0400, Denis Gerasimov wrote:
> I put the following lines to my VirtualHost section:
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} ^.*\.html$
> RewriteRule ^.*$ /index.php?url=%{REQUEST_URI}&%{QUERY_STRING} [L]
> e.g.
> /news/index.html?var1=value1 -> /index.php?url=/news/index.html&var1=value1
> However I noticed that url is not encoded in this case. Is there something
> like urlencode() in Apache to fix that? Also are thre any better ways of
> handling this?

The RewriteCond line is unnecessary, and you don't need to manually add
the query string. Remove the RewriteCond line and use the 'QSA'
RewriteRule flag:

RewriteEngine on
RewriteRule ^.*\.html$  /index.php?url=%{REQUEST_URI} [L,QSA]

If you want to urlescape, you can make use of the internal 'unescape'

RewriteEngine on
RewriteMap unescape int:unescape
RewriteRule ^.*\.html$  /index.php?url=${unescape:%{REQUEST_URI}}

Tweak as needed. =)


<huey> dd of=/dev/fd0 if=/dev/flippy bs=1024
<huey> ^^^ Making Flippy Floppy

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message