Posts: 76
Name: Nick Cousins
Location: Northern Ireland
|
I'm building a web application that hosts multiple websites using one codebase, and loading all of the content from a database based on the URL used to access it.
So I configure all my domains to point to one IP address, and the server treats all requests the same (i.e. no virtual hosts) - but my PHP script loads different sites according to the domain passed.
When in development the system is designed to use a parameter passed in the URI as the domain instead of the actual hostname:
e.g. example.com would be accessed by typing in http://development.server.com/example.com
This means we can try out sites without them actually being set live.
The issue I have is that the HTACCESS files on the development and live servers need to be different because I can't get the standard Regex "Zero or more of..." principle to work in mod_rewrite.
This rule rewrites http://development.server.com/example.com/page to what would normally be http://example.com/page:
ReWriteRule ^([a-zA-Z0-9._-]*)\/([^\/\.]+)\/?$ /site.php?domain=$1&p=$2 [NC,L,NS]
Works fine at http://development.server.com/example.com
or if I access http://live.server.com/example.com
However - if I point example.com to the IP of the live server it will not work and I have to change all of the rewrites to:
ReWriteRule ^\/([^\/\.]+)\/?$ /site.php?domain=$1&p=$2 [NC,L,NS]
I'm obviously doing something ridiculously stupid here - anyone got any ideas what it might be?
__________________
Join Please login or register to view this content. Registration is FREE
Knowledge is power. Never underestimate the power of stupid people in large numbers.
Last edited by HandCoder; 12-21-2009 at 04:10 PM..
|