Apache Server configuration support - RewriteRule RegEx question and RewriteLog issue

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2006 > RewriteRule RegEx question and RewriteLog issue





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 RewriteRule RegEx question and RewriteLog issue
liebermann@gmail.com

2006-08-16, 7:33 am

Hi,

I'm trying to write a rule that will capture "whatever" - in the
following examples:

http://hostname/dir/whatever
http://hostname/dir/whatever/
http://hostname/dir/whatever/no-matter-what

All I want is the first "whatever" (of course, "whatever" is unknown).

I did the following rule in .htaccess under directory "dir":
RewriteRule ^([^/]+)/$ mypage.php?input1=$1

But this will only capture http://hostname/dir/whatever/

How do I make it more general so it will caprute into $1 in the other
cases as well?

===
2nd question:
While trying to figure it, I also tried to activate the log like that:
RewriteLog "c:/wamp/Apache/logs/rewrite.log"
RewriteLogLevel 9

All I got was "internal error or misconfiguration" from the webserver.

I'm using Apache under XP (as part of the WAMP).

Thank you all,

Rik

2006-08-16, 7:33 am

liebermann@gmail.com wrote:
> Hi,
>
> I'm trying to write a rule that will capture "whatever" - in the
> following examples:
>
> http://hostname/dir/whatever
> http://hostname/dir/whatever/
> http://hostname/dir/whatever/no-matter-what
>
> All I want is the first "whatever" (of course, "whatever" is unknown).
>
> I did the following rule in .htaccess under directory "dir":
> RewriteRule ^([^/]+)/$ mypage.php?input1=$1
>
> But this will only capture http://hostname/dir/whatever/
>
> How do I make it more general so it will caprute into $1 in the other
> cases as well?


RewriteRule ^([^/]+)/.*$ mypage.php?input1=$1

> ===
> 2nd question:
> While trying to figure it, I also tried to activate the log like that:
> RewriteLog "c:/wamp/Apache/logs/rewrite.log"
> RewriteLogLevel 9
>
> All I got was "internal error or misconfiguration" from the webserver.


Nothing else in the error.log?

> I'm using Apache under XP (as part of the WAMP).


I'm not sure wether WAMP automatically logs rewrites, but it can only be
declared once, which might be your problem.

What happens if you use "logs/rewrite.log"?
And if that file doesn't exist, what happens of you create an empty file
named rewrite.log?

Grtz,
--
Rik Wasmus


HansH

2006-08-16, 7:33 am

<liebermann@gmail.com> schreef in bericht
news:1155718260.417103.239460@i3g2000cwc.googlegroups.com...

> http://hostname/dir/whatever
> http://hostname/dir/whatever/
> http://hostname/dir/whatever/no-matter-what
>
> All I want is the first "whatever" (of course, "whatever" is unknown).
>
> I did the following rule in .htaccess under directory "dir":
> RewriteRule ^([^/]+)/$ mypage.php?input1=$1
>
> But this will only capture http://hostname/dir/whatever/
>
> How do I make it more general so it will caprute into $1 in the other
> cases as well?

Try
RewriteRule ^([^/]+)/? mypage.php?input1=$1

HansH


liebermann@gmail.com

2006-08-16, 1:28 pm


HansH wrote:
> Try
> RewriteRule ^([^/]+)/? mypage.php?input1=$1
>
> HansH


Thanks.
If I do that, the parameter passed as $1 is not "whatever", it's
"index.php" for some reason.

Thanks again,

liebermann@gmail.com

2006-08-16, 1:28 pm


Rik wrote:
>
> RewriteRule ^([^/]+)/.*$ mypage.php?input1=$1
>


Same result :-( I did that before asking here, this is the strange
thing, because as far as I understand RegEx, it should have worked
indeed.

>
> Nothing else in the error.log?
>
>
> I'm not sure wether WAMP automatically logs rewrites, but it can only be
> declared once, which might be your problem.
>
> What happens if you use "logs/rewrite.log"?


Same result:
"he server encountered an internal error or misconfiguration and was
unable to complete your request."

> And if that file doesn't exist, what happens of you create an empty file
> named rewrite.log?


Nothing. The file remains empty.

> Grtz,
> --
> Rik Wasmus


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com