Jump to content

regex mysteries


Henrik

Recommended Posts

I am trying to use parked domains as managed domains in a wiki farm environment, so I want to mimic frame forwarding or phantom domains.

As a test I enter this into the browser: http://bechmann.ca/projects/frontpage.html

and have this in .htaccess:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^bechmann\.ca$ [OR]
RewriteCond %{HTTP_HOST} ^www\.bechmann\.ca$
RewriteRule ^$ osscommons/home/osscommons.html [L]
RewriteCond %{HTTP_HOST} ^bechmann\.ca$ [OR]
RewriteCond %{HTTP_HOST} ^www\.bechmann\.ca$
RewriteRule ^([^/]+)/([a-z.]+)$ osscommons/$1/$2 [L]

which works, but is not general enough.

But when I substitute

RewriteRule ^([^/]+)/(*+)$ osscommons/$1/$2 [L]

for the last line, I get Internal Error

and when I do

RewriteRule ^(*+)$ osscommons/$1 [L]

I also get an internal server error.

Can anyone explain?

Thanks!

- Henrik
Link to comment
Share on other sites

  • 4 months later...
In case anyone is interested I have since found a solution:

RewriteEngine on
RewriteBase /
#allow subdomains
RewriteCond %{HTTP_HOST} !^(www\.)?([^.]*)(\.ca|\.com|\.org)$
RewriteRule ^ - [L]
#collect core domain name (coreName)
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]*)(\.ca|\.com|\.org)$
RewriteRule ^ - [E=coreName:%2]
#specific exceptions...
RewriteCond %{ENV:coreName} ^bechmannsoftware$
RewriteRule ^(.*)$ http://software.bechmann.ca/$1 [R,L]
RewriteCond %{ENV:coreName} ^politicalreader$
RewriteRule ^(.*)$ http://politics.ireader.ca/$1 [R,L]
RewriteCond %{ENV:coreName} ^economicsreader$|^governancereader$|^newsreader$
RewriteCond %{ENV:coreName} ^(.+)reader$
RewriteRule ^(.*)$ http://%1.ireader.ca/$1 [R,L]
#RewriteCond %{ENV:coreName} ^bechmann$
#RewriteRule ^(.*)$ http://software.bechmann.ca/$1 [R,L]
RewriteCond %{ENV:coreName} ^dufferinpark$|^parkcommons$|^communitycommons$|^businesscommons$
RewriteRule ^ - [L]
#generic handling...
#provide file request: index.php if available or index.html by default
RewriteCond %{DOCUMENT_ROOT}/%{ENV:coreName}/index.php -f
RewriteRule ^$ http://%{HTTP_HOST}/index.php [R,L]
RewriteRule ^$ http://%{HTTP_HOST}/index.html [R,L]
#add missing trailing / for directory requests to avoid reversion to cananical domain
RewriteCond $1 ![.]
RewriteCond %{DOCUMENT_ROOT}/%{ENV:coreName}/$1 -d
RewriteRule ^(.+[^/])$ http://%{HTTP_HOST}/$1/ [R,L]
#prevent recursion through sentinel file
RewriteCond %{DOCUMENT_ROOT}/$1/%{ENV:coreName}.identifier.DoNotTouch -f
RewriteRule ^([^/]*) - [S=2]
#hack for pmwiki re form url parameter - replace wiki.php/ with wiki.php?n=
RewriteRule ^(.*/wiki.php)(/)(.*)$ http://%{HTTP_HOST}/$1?n=$3 [QSA,R,L]
#silently insert subdirectory for public data
RewriteRule ^(.*)$ %{ENV:coreName}/$1

Note that this requires a sentinel file in each directory to stop recursion.

- Henrik
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.