Discussion:
RewriteMap never matching
(too old to reply)
Shake
2012-05-22 11:49:25 UTC
Permalink
Hi all,

I have a XAMPP installed on my own machine. using an Apache2 over
windows 7 64bits.

And I am fighting with the RewriteMap. By now, it is winning the battle.

I have this:

[...] are to avoid long unnecesary paths here. Are right on the files

On the virtualhost configuration:
--------------------------
[...]
RewriteEngine on
RewriteLog "[...]logs/rewrite.log"
RewriteLogLevel 9
RewriteMap blogmaps "txt:[...]/blogmaps.txt"
[...]
--------------------------

The [...]/blogmaps.txt file:
--------------------------
##
## Blog mapping.
##
www.domain1.dev domain1
www.domain1.com domain1
www.domain2.dev domain2
www.domain2.com domain2
--------------------------
(.dev is a local for development "tld" we use)

And finally, the .htaccess
--------------------------
[...]
Rewriterule ^blog/$ ${blogmaps:%{SERVER_NAME}|NONE}/blog/index.php
[NC,L,QSA]
[...]
--------------------------

Always returns NONE. I do some test, Like:

--------------------------
RewriteCond %{SERVER_NAME} ^(.+)
RewriteCond %1 ^(.+)
RewriteCond ${blogmaps:%1} (.+)
Rewriterule ^blog/$ %1/blog/index.php
--------------------------

And I get this form the Rewrite Log:

--------------------------
RewriteCond: input='www.domain1.dev' pattern='^(.+)' => matched
RewriteCond: input='www.domain1.dev' pattern='^(.+)' => matched
RewriteCond: input='' pattern='(.+)' => not-matched
--------------------------


Trying just:
--------------------------
RewriteCond %{SERVER_NAME} ^(.+)
RewriteCond ${blogmaps:%1} (.+)
Rewriterule ^blog/$ %1/blog/index.php
--------------------------
I get
--------------------------
RewriteCond: input='www.domain1.dev' pattern='^(.+)' => matched
RewriteCond: input='' pattern='(.+)' => not-matched
--------------------------

And a lot of test, and tries have always the same result, included doing
(hardcoding the domain):

RewriteCond ${blogmaps:www.domain1.dev} (.+)
Rewriterule ^blog/$ %1/blog/index.php

And the result is always input='' when using the RewriteMap
${blogmaps:something}

I spent a lot of time checking syntaxis and these kind of mistakes,
After this, searching for answers on the web. Trying to discover is I
was doing a common mistake or something... And after this, I started to
see if perhaps the trouble is with using windows....

But I found no answers. So finally , and a little desesperated :) I ask
for help. Or a clue... to solve this "mistery" :)

thanks to all.

Rgds.
Jim
2012-05-22 15:24:31 UTC
Permalink
On Tue, 22 May 2012 13:49:25 +0200, in alt.apache.configuration, Shake
Post by Shake
And finally, the .htaccess
--------------------------
[...]
Rewriterule ^blog/$ ${blogmaps:%{SERVER_NAME}|NONE}/blog/index.php
[NC,L,QSA]
[...]
--------------------------
I would suggest using %{HTT_HOST} which is derived from the request
instead of %{SERVER_NAME} which is info about the server.

HTH,
Jim
Jim
2012-05-22 15:25:14 UTC
Permalink
On Tue, 22 May 2012 11:24:31 -0400, in alt.apache.configuration, Jim
Post by Jim
On Tue, 22 May 2012 13:49:25 +0200, in alt.apache.configuration, Shake
Post by Shake
And finally, the .htaccess
--------------------------
[...]
Rewriterule ^blog/$ ${blogmaps:%{SERVER_NAME}|NONE}/blog/index.php
[NC,L,QSA]
[...]
--------------------------
I would suggest using %{HTT_HOST} which is derived from the request
instead of %{SERVER_NAME} which is info about the server.
Make that %{HTTP_HOST}.
Post by Jim
HTH,
Jim
Shake
2012-05-23 08:22:26 UTC
Permalink
Post by Jim
On Tue, 22 May 2012 13:49:25 +0200, in alt.apache.configuration, Shake
Post by Shake
And finally, the .htaccess
--------------------------
[...]
Rewriterule ^blog/$ ${blogmaps:%{SERVER_NAME}|NONE}/blog/index.php
[NC,L,QSA]
[...]
--------------------------
I would suggest using %{HTT_HOST} which is derived from the request
instead of %{SERVER_NAME} which is info about the server.
Hello Jim.

I think SERVER_NAME is the good one. The rule have to "prepare" a path
to a file taken care of which virtualhost is serving de file. And not
what the client was requested. For example, I have to use the same if
the client entered by domain name or by IP number.
Shake
2012-05-23 08:25:20 UTC
Permalink
Solved?

Well, now it works but....

I get all this stuff running with putting the rewritemap outside de
virtulahost. In a "global" manner.

Changing this:

On apache configuration:
--------------------------
[...]
<virtual host...>
[...]
RewriteMap blogmaps "txt:[...]/blogmaps.txt"
[...]
</virtual host>
[...]
--------------------------

For this other thing:
--------------------------
RewriteMap blogmaps "txt:[...]/blogmaps.txt"
[...]
<virtual host...>
[...]
</virtual host>
[...]
--------------------------

And the blogmaps started to work and return values correctly.

Greetings

Loading...