httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Martin <>
Subject [users@httpd] Apache2: rewrite strangeness and _default_ virtual hosts
Date Sun, 22 Aug 2004 07:42:40 GMT
I've struggled with two issues since starting to use Apache2:

1) a wiki that i use has the option to have cleaner looking urls by 
using rewrite rules. The authors suggestions never worked for me and 
after extensive tinkering It seemed to me as though Apache2 is 
following different rules for rewrite than Apache1.3

The rules i'm trying to use:
	RewriteEngine on
	RewriteCond %{REQUEST_FILENAME}       !-f
	RewriteCond %{REQUEST_FILENAME}       !-d
	RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
	RewriteRule ^index.php$               doku.php

There seemed to be two problems...

	Problem 1: the complete string being handed to the rule was not the 
url but a complete filesystem path. These rules seem to work for 
everyone else but me -- But the $1 callback was definately containing 
way more than the author expected. I got around this by adding a bit 
more of the path to the pattern so it only matched the last parts of 
the string, like this: RewriteRule /wiki/(.*) doku.php?id=$1 [QSA,L]

	Problem 2: It would never match the index.php rule. I thought the full 
path thing was happening for this rule too, but as far as i could tell 
the real problem was that the two conditions were getting applied to 
both rules, where the author only intended the conditions to match the 
first rule. There is indeed an index.php file in the directory (which 
just does a redirect to doku.php anyway) so it fails the file condition 
and thus the rewrite rule is never executed. It opens the index which 
sends the header to redirect to doku.php and in the process the entire 
query string gets blown away and you're back at square one.

2) The second big issue i've had with apache2 is concerning the 
_default_ virtual host. When people visit my site currently by using a 
full hostname which the DNS resolves to my server, yet apache doesn't 
have a name-based virtual host for ( for instance) it 
sends them to the first virtual host defined, just like apache docs 
specify. I didn't want this, so i thought i'd use the _default_ host as 
explained in the docs. Problem is, if i place the _default_ host 
anywhere in my configuration it ALWAYS sends ALL clients to that 
documentroot rather than to the specific hosts that the users may have 

The documentation clearly states, "A default vhost never serves a 
request that was sent to an  address/port that is used for name-based 
vhosts." But this is clearly not the case with my configuration. As 
soon as i add the _default_ it sends all traffic there regardless of 
the other virtualhosts.

Thanks for any input and help anyone can give. I'm completely out of 
ideas and have read everything i can find about these subjects.

View raw message