[pmwiki-devel] help with htaccess coding?
Henrik
henrik.bechmann at sympatico.ca
Wed Nov 15 11:35:15 CST 2006
To answer my own question:
Each time a rewrite is executed in htaccess, the process iterates
through the instructions from the beginning. Therefore the rewrite code
from the original question below generates an infinite loop.
Here is the code that works. Thus for example I have osscommons.ca as a
domain name parked on my main account bechmannsoftware.com. The parked
domain is pointed to bechmannsoftware.com web host servers.
osscommons.ca data is in /osscommons/ (from the root public directory of
bechmannsoftware.com) but the user only sees osscommons.ca/.... So when
the user types osscommons.ca, after redirections and such the user sees
osscommons.ca/home/osscommons.html instead of
osscommons.ca/osscommons/home/osscommons.html. With the following code I
can set up any number of independent (-looking) websites (managed with
common code) within one web hosting account (they will all be wiki
fields), just for the cost of the domain names. The only hack is the
requirement to create a zero-byte file
"<domaindirname>.identifier.DoNotTouch" in each domain's root directory,
to stop recursion.
RewriteEngine on
RewriteBase /
#subdomains are filtered out, they do not need processing
RewriteCond %{HTTP_HOST} !^(www\.)?([^.]*)(\.ca|\.com|\.org)$
RewriteRule (.*) - [L]
#the coreName, which is also the subdirectory name is extracted
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]*)(\.ca|\.com|\.org)$
RewriteRule (.*) - [E=coreName:%2]
#add-on subaccounts are filtered out (only five are available with my
main account), they do not need processing
RewriteCond %{ENV:coreName}
^dufferinpark$|^parkcommons$|^communitycommons$|^businesscommons$|^wikiwebsites$
RewriteRule (.*) - [L]
#where only the domain name is given by the user, add index.php or
index.html as available
RewriteCond %{DOCUMENT_ROOT}/{ENV:coreName}/index.php -f
RewriteRule ^$ http://%{HTTP_HOST}/index.php [R,L]
RewriteRule ^$ http://%{HTTP_HOST}/index.html [R,L]
#if the identifier file is available through the current root directory,
we are done, skip the next instruction to avoid recursion
RewriteCond %{DOCUMENT_ROOT}/$1/%{ENV:coreName}.identifier.DoNotTouch -f
RewriteRule ^([^/]*) - [S=1]
#this is what does the actual work/magic, silently insert required
internal subdirectory
RewriteRule ^(.*)$ %{ENV:coreName}/$1
I still have some issues: eg. path to shared farm directory, and path to
shared software (eg phpList). Thinking of using symlinks for this, but
not sure yet...
Progress.
- Henrik
Henrik wrote:
> All,
>
> I'm trying to set up a wiki farm, such that "parked" domain names are
> internally redirected to the appropriate paths. As an example I have
> bechmann.ca parked on to bechmannsoftware.ca.
>
> There appears to be something really basic that I'm missing.
>
> In htaccess if I write
>
> RewriteEngine on
> RewriteBase /
> RewriteCond %{HTTP_HOST} ^bechmann\.ca$ [OR]
> RewriteCond %{HTTP_HOST} ^www\.bechmann\.ca$
> RewriteRule ^(.*) $1
>
> and then enter bechmann.ca to the browser URL field, I get an error 500,
> though to me this looks like it should just take what it finds and
> substitute itself, ie no net change.
>
> if I enter bechmann.ca/test.php I'm OK (there is a test.php file I put
> there for feedback).
>
> if I enter bechmann.ca/osscommons/home/test.php I'm OK
>
> If I change the RewriteRule to
>
> RewriteRule ^(.*) /osscommons/home/$1
>
> And then enter bechmann.ca/test.php I get an error 500, although it
> looks to me like it should take test.php and produce
> /osscommons/home/test.php
>
> If I change the RewriteRule to
>
> RewriteRule ^(.*) /var/vhosts2/henrik/public_html/osscommons/home/test.php
>
> and enter bechmann.ca
>
> It works, but if I do
>
> RewriteRule ^(.*)
> /var/vhosts2/henrik/public_html/osscommons/home/osscommons.html
>
> and enter bechmann.ca
>
> I get the contents of the html page, but the styling (ie the relative
> directory addressing) is lost.
>
> If I do
>
> RewriteRule ^(.*) /var/vhosts2/henrik/public_html/osscommons/home/$1
>
> and enter bechmann.ca/test.php or bechmann.ca/osscommons.html I get an
> error 500
>
> I have no freakin' idea what's going on :-( and I've been tinkering
> for hours.
>
> What am I missing here? Can anyone give me a concept? or a configuration
> clue??
>
> Thanks
>
> - Henrik
>
>
--
Henrik Bechmann
www.osscommons.ca
www.bechmannsoftware.com
Webmaster, www.dufferinpark.ca
More information about the pmwiki-devel
mailing list