On 04/23/2009 03:22 AM, Tom Evans wrote:
Thank you, Tom, for taking the time out to help with this and share your solution with me. I'm not sure, though, I'm going to be able to use it immediately. I've decided, therefore, to just suck it up and write out the domain names directly. I hope your module will find its way into the official httpd release, though.On Wed, 2009-04-22 at 23:22 +0800, Basil Mohamed Gohar wrote:On 04/22/2009 11:11 PM, Tom Evans wrote:On Wed, 2009-04-22 at 22:30 +0800, Basil Mohamed Gohar wrote:On 04/22/2009 10:17 PM, Eric Covener wrote:On Wed, Apr 22, 2009 at 10:14 AM, Basil Mohamed Gohar <abu_hurayrah@xxxxxxxxxxxxxxxxx> wrote:Outside of htaccess, the pattern is compiled at startup, so you can't use variables (because they depend on parts of the request, even ServerName). IIUC It's feasible in per-directory, but not implemented.So, what this means is it's not possible as it stands right now, correct?Correct. You can usually get to the same ultimate result by putting the variables in the 2nd argument and being more clever with captures and multiple conditions, etc. If you can describe what your end goal is, someone here might be able to help construct a ruleset.Thanks. It's quite simple, actually. What I want to do is direct all domains that fall under a virtualhost which has many server aliases to one canonical domain. So, for example, if my canonical name is www.example.com, and someone accesses example.com or example.net (all of which are aliases in VirtualHost block), I want a redirect to be issued pointing to the canonical ServerName value (www.example.com). Since this is already stored in %{SERVER_NAME}, I thought it would be best to use it, because I have this kind of behavior on many, but not all, VirtualHosts. It would save me a lot of time.RewriteCond %{HTTP_HOST} !^(www.foo.com)$ RewriteRule ^/(.*) http://www.foo.com/$1 [R=301,L] This is an FAQ iirc? http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html#canonicalhost HTH TomWriting it by hand for all the different VirtualHosts is what I was trying to avoid. Doing it with variables was the goal, and it seems that is not possible. I've been writing it by hand for years now. ;)So, I pulled out the canonicalization module I had, it didn't quite do it how you initially wanted (you had to specify the host name you wanted to be canonical), I can see the benefit of having it that way. Also, it was only 8 lines to add :) http://svn.nubtek.com/svn/public/mod_server_name_c14n/mod_server_name_c14n.c Have a read of it, it really is a simple module. This is the vhost I use for testing it: <VirtualHost *:80> ServerName canon ServerAlias notcanon also-not-canon DocumentRoot /var/empty <Directory /var/empty> Order allow,deny Allow from all </Directory> ServerNameIsCanonical On #SetCanonicalServerName canon </VirtualHost> It is an extra module to add, but its just a tiny one :) Assuming your apache installation is correct, just download the .c file to a folder somewhere and run apxs -c mod_server_name_c14n.c sudo apxs -i -a mod_server_name_c14n.c ``apxs -c`` compiles the module, ``apxs -i -a`` installs it to your apache modules folder, and activates it (adds the LoadModule line) in your httpd.conf Cheers Tom
--------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx