Re: [users@httpd] Rewriting all URLs to /index.php

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

 



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

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]

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