Web Servers on Unix and Linux - mod_rewrite problem

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > February 2007 > mod_rewrite problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author mod_rewrite problem
Nico Haberzettl

2007-02-21, 7:20 am

Hi there,

I have a problem with Apache and the mod_rewrite-module.

I want to rewrite e.g. the following URL
http://www.my-server.com/category/1/Some_Name
to
http://www.my-server.com/index.php?category=1

Note: either the first and the second parameter must be
variable ("category" can be "profile" or "menue").

This is the rule I've tried, but it just leads to the 404

RewriteEngine on
RewriteRule ^/(kategorie|profile|menue)/(0-9)$ /index.php?$1=$2

Any hints?
greetings from bavaria
Nico
Bob Smith

2007-02-21, 1:15 pm

On 2/21/2007 7:28 AM, Nico Haberzettl wrote:
> Hi there,
>
> I have a problem with Apache and the mod_rewrite-module.
>
> I want to rewrite e.g. the following URL
> http://www.my-server.com/category/1/Some_Name to
> http://www.my-server.com/index.php?category=1
>
> Note: either the first and the second parameter must be
> variable ("category" can be "profile" or "menue").
>
> This is the rule I've tried, but it just leads to the 404
>
> RewriteEngine on RewriteRule ^/(kategorie|profile|menue)/(0-9)$
> /index.php?$1=$2


You probably want [0-9] instead of (0-9).

--
________________________________________
_
Bob Smith -- bsmith@sudleydeplacespam.com

To reply to me directly, delete "despam".
Nico Haberzettl

2007-02-21, 1:15 pm

"Bob Smith" <bsmith@sudleydeplacespam.com> schrieb im Newsbeitrag
news:jwZCh.3290>> RewriteEngine on RewriteRule
^/(kategorie|profile|menue)/(0-9)$
>
> You probably want [0-9] instead of (0-9).


mh, both of them, I need the range [0-9] and the named match, so
its ([0-9]).
By now I found the solution: deleting the ^ at the beginning and the $
at the end AND correcting the matching-value works.

RewriteRule (kategorie|profil|menue)\/([0-9])
http://www.my-server.de/index.php?$1=$2

works fine. The only "nice to have"-thingy would be a redirection to the
rewritten
URL, leaving the "visible" URL untouched (load the URL in the rewritten form
but
leave e.g. www.my-server.de/kategorie/1/blabla_BLA in the adresse bar, as a
solution
via ErrorDocument would do)

thanks for your reply
Nico Haberzettl

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com