> -----Original Message----- > From: Noah [mailto:sitz@xxxxxxxxxxxx] > Sent: Wednesday, March 30, 2005 10:30 AM > To: users@xxxxxxxxxxxxxxxx > Subject: Re: [users@httpd] Rewriting all URLs to /index.php > > 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' > rewritemap: > > RewriteEngine on > RewriteMap unescape int:unescape > RewriteRule ^.*\.html$ /index.php?url=${unescape:%{REQUEST_URI}} > [L,QSA] > > Tweak as needed. =) Thanks, it works. But I've got one more problem. Here is what I need: /news/details/123.html -> /news/details.html?id=123 -> /index.php?url=/news/details.html&id=123 I thought the following would work but I was wrong: RewriteEngine on RewriteMap unescape int:unescape RewriteRule ^.*\/$ $1index.html [L,R] RewriteRule ^/news/details/(.+)\.html$ /news/details.html?id=$1 [N] RewriteRule ^.*\.html$ /index.php?url=${unescape:%{REQUEST_URI}} [L,QSA] %{REQUEST_URI} is still /news/details/123.html! Should I get rid of %{REQUEST_URI} and do pattern matching instead (something like ^[^?]+\?(.*)$ )? Does anyone have an idea how to handle this the right way?.. > > --n > > -- > <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: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 --------------------------------------------------------------------- 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