You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Thomas Klausner <do...@zsi.at> on 2004/06/21 13:56:45 UTC

OT: mod_rewrite question

Hi!

Sorry for the offtopic post, but I thought somebody here just has to know
the answer to my problem...

I want to rewrite URIs (using Apache 1.31) from something like this

  http://somehost/somedir/123.html

to

  http://somehost/somedir/view?id=123
  
I tried:

RewriteRule ^/(.*)/(.*).html$    /$1/view?id=$2

which nearly works, as it says in the logs that:
  rewrite /stepsdok/28.html -> /stepsdok/view?id=28
  
But mod_rewrite than prepends DocumentRoot

If I set RewriteBase to / the Rule doesn't match anymore, even if I alter
the Rule:
  RewriteBase /
  RewriteRule ^(.*)/(.*).html$    /$1/view?id=$2


Does anybody know who to get this working? Or where I can find more info
(besides http://httpd.apache.org/docs/mod/mod_rewrite.html)



-- 
#!/usr/bin/perl                               http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: OT: mod_rewrite question

Posted by "Randal L. Schwartz" <me...@stonehenge.com>.
>>>>> "Thomas" == Thomas Klausner <do...@zsi.at> writes:

Thomas> Sorry for the offtopic post, but I thought somebody here just has to know
Thomas> the answer to my problem...

Thomas> I want to rewrite URIs (using Apache 1.31) from something like this

Thomas>   http://somehost/somedir/123.html

Thomas> to

Thomas>   http://somehost/somedir/view?id=123

Since this is a mod_perl mailing list, the way to bring it
back on-topic is to CHUCK MOD_REWRITE if you have mod_perl
available.  A PerlTransHandler is far more flexible than
mod_rewrite, and uses a much more familiar syntax. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<me...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: OT: mod_rewrite question

Posted by Vadim <va...@lernet.ru>.
> Hi!
>
> Sorry for the offtopic post, but I thought somebody here just has to know
> the answer to my problem...
>
> I want to rewrite URIs (using Apache 1.31) from something like this
>
>   http://somehost/somedir/123.html
>
> to
>
>   http://somehost/somedir/view?id=123
>
> I tried:
>
> RewriteRule ^/(.*)/(.*).html$    /$1/view?id=$2
>
> which nearly works, as it says in the logs that:
>   rewrite /stepsdok/28.html -> /stepsdok/view?id=28
>
> But mod_rewrite than prepends DocumentRoot
>
> If I set RewriteBase to / the Rule doesn't match anymore, even if I alter
> the Rule:
>   RewriteBase /
>   RewriteRule ^(.*)/(.*).html$    /$1/view?id=$2
>
>
> Does anybody know who to get this working? Or where I can find more info
> (besides http://httpd.apache.org/docs/mod/mod_rewrite.html)


this rule works fine for me
RewriteRule  ^shop/(.
+)$         /cgi-bin/content.pl?path=$1&query=%{QUERY_STRING}       [L]



-- 
Vad

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html