httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis Gerasimov" <denis.gerasi...@vekos.ru>
Subject RE: [users@httpd] Rewriting all URLs to /index.php
Date Thu, 31 Mar 2005 06:45:35 GMT

> 
> On Wed, Mar 30, 2005 at 06:08:17PM +0400, Denis Gerasimov wrote:
> 
> > 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 ^[^?]+\?(.*)$ )?
> 
> Your first RewriteRule may not do what you want, since $1 will be empty
> (no parenthese used in the LHS of that Rule);

Well spotted... however, it works i.e. /news/ -> /news/index.html

> 
> If I'm understand you correctly, something like this:
> 
> RewriteEngine on
> RewriteMap unescape int:unescape
> RewriteRule ^/news/([^/]+)/([0-9]+)\.html$ \
>     /index.php?url=${unescape:/news/$1.html}&id=$2 [L,QSA]

No, that is not what I need :-(. Rewriting to index.php should work
everywhere.

The thing is that requested URL, say /demo/test1.html, is internally mapped
to appropriate file containing PHP class, php/demo/test1.class.php in that
case. However, I want to have user-friendly URLs like /news/details/123.html
that should be mapped to php/news/details.class.php, not
/news/details/123.class.php

> 
> Note that this makes several assumptions:
> 
> 1) all paths you want to rewrite start with /news/;
> 2) the directory element immediately after '/news/' will be the name of
> the html file in the Rewritten path;
> 3) the id is always numeric
> 
> Again, tweak as needed.
> 
> --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@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org


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