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
https://forums.phpfreaks.com/topic/26849-regex-mysteries/
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
https://forums.phpfreaks.com/topic/26849-regex-mysteries/#findComment-213586
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.