Apache Server configuration support - Mod_rewrite question

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > February 2006 > Mod_rewrite question





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

2006-02-19, 5:52 pm

Hi group,

I am trying to translate an url like this:

http://www.domain.com/L1/L2/L3/L4 to something like this:
http://www.domain.com/index.php?key=L1_L2_L3_L4

I am working my way there..... but something is not clear to me.
I am using the following rewriterule in my .htaccess

RewriteEngine on
RewriteRule /(.*)/?$ index.php?key=$1 [L]

Index.php has the following structure:

$key=$_GET['key'];
echo "PATH = $key";


The result, however, is:

PATH = L2/L3/L4

instead of

PATH = L1/L2/L3/L4

like I expected.....

What am I doing wrong in my regexp?

Thank you for your hints/help!

Greetz, Michel


Robert Ionescu

2006-02-19, 5:52 pm

AquAvia wrote:
> RewriteEngine on
> RewriteRule /(.*)/?$ index.php?key=$1 [L]

[...]
> What am I doing wrong in my regexp?


The request matches in a .htaccess file only against a filepath (-> in
/.htaccess it would be L1/L2/L3/L4 - no leading slash), not against a
local URL.

RewriteEngine on
RewriteRule ^([^.]+)/?$ /index.php?key=$1 [L]

--
Robert
AquAvia

2006-02-19, 5:52 pm

> The request matches in a .htaccess file only against a filepath (-> in
> /.htaccess it would be L1/L2/L3/L4 - no leading slash), not against a
> local URL.
>
> RewriteEngine on
> RewriteRule ^([^.]+)/?$ /index.php?key=$1 [L]
>
> --
> Robert


Thank you Robert.... I can now stop banging my head against the wall....
Maybe I should have myself slapped instead.

Great help!


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com