Forum Moderators: phranque

Message Too Old, No Replies

vhost_alias & (www.)? for interpolation

How do I get a different position if the domain is longer

         

apache_user

2:56 pm on Jun 24, 2005 (gmt 0)

10+ Year Member



I'm struggling with how the vhost_alias makes the server name available for interpolation. Part of the problem is I don't want to rewrite the host if the 'www' is excluded. So, if someone visits example.com, their URL doesn't change, and they browse the site just as someone who visited www.example.com (as though there was a ServerAlias directive). With that in mind, what variable do I use for directory interpolation? If I use %2+ and they visit example.com, it'll look for '.../com/'. Now, I have the additional complication of needing to host longer sites, like example.st.us, where I would want to use %3+ instead.

Am I asking the impossible?

apache_user

2:38 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



anyone?

jdMorgan

10:14 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



apache_user,

Welcome to WebmasterWorld!

I'm not following your usage of "interpolate" here, but generally, the problem is solvable by enclosing the optional elements and their trailing periods in parentheses and adding "?" to make that group optional, as in:


(www\.)?([^.]+)\.(st\.)?us

In this case, you would always use %2 to back-reference the domain, even if %1 and %3 are empty.

How you implement this depends on which parts of the domain are fixed and which are variable. If your domain taxonomy varies greatly, you may need to use multiple rules.

Jim

apache_user

7:49 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



When I say "interpolated", I mean it in the context it is used here:

[httpd.apache.org...]

It doesn't appear that I have the luxury of using a regular expression to match the domain; it looks like the mod does all of that for me.

Am I forced into rewriting the 'www' back on to a URL if it's missing?