NotionCommotion Posted November 11, 2014 Share Posted November 11, 2014 I have a script called getstarted who's purpose is to create microsights which are located as: /var/www/html/microsite1/index.php /var/www/html/microsite1/lib/ (symbolic link) /var/www/html/microsite1/administrator/index.php /var/www/html/microsite2/index.php /var/www/html/microsite2/lib/ (symbolic link) /var/www/html/microsite2/administrator/index.php /var/www/html/microsite3/index.php /var/www/html/microsite3/lib/ (symbolic link) /var/www/html/microsite3/administrator/index.php Each of the index.php files looks like: define( '_VSEXEC', 1 ); // Set flag to indicate that this is a parent $file=__FILE__; $type='back'; //or front require('/path/to/mainfile.php'); Question: Should the microsites be virtual servers or just subfolders? If there are many, seems like virtual servers are not a good solution, right? Instead of accessing a microsite as http://mydomain.com/microsite1/index.php and http://mydomain.com/microsite1/administrator/index.php, I would like to do so as http://microsite1.mydomain.com/index.php and http://microsite1.mydomain.com/administrator/index.php. How is this best accomplished? The key to the microsites being unique is the name of the folder (microsite1, 2, 3, etc). Note that the user may later change the sites name (i.e. microsite1 to bobs_site) as well as the administrator link (i.e. administrator to bobs_backend) using the administrator PHP application. My mainfile.php which is included in each of the index.php files simply gets the name by using basename(dirname($file)), and then queries the DB using this name to get the microsite specifics. Is there anything inherently wrong with this approach? A separate session cookie is used for the front microsite (http://mydomain.com/microsite1/index.php) and the accompanying administrator microsite (http://mydomain.com/microsite1/administrator/index.php). The same session cookie should be used whether accessed as http://mydomain.com/microsite1/index.php or http://microsite1.mydomain.com/index.php, and the same for the two admin entry points (note that www.mydomain.com is rewritten to mydomain.com). I originally started asking this question in post http://forums.phpfreaks.com/topic/292398-help-understanding-cookies-domains-and-paths/, but don't think I was clear with my requirements. Currently, I have the session cookies for both the front and admin site as domain ".mydomain.com" and path "/microsite1/" The accompanying session is something like array('front'=>array('bla','bla'),'admin'=>array('bla','bla')). In hindsight, I think this was a poor decision as front users and admin users can logoff which should delete their session, and this causes both the front and admin session to be deleted if they are concurrently logged as as both. Recommendations how best to implement this (no detailed code required, just provide general approach). Thank you REFERENCE ONLY. My website has five pages which are implemented using files home.html, features.html, pricing.html, and main.php located in my HTML root directory (/var/www/html). home.html, features.html and pricing.html are accessed directly. main.php is accessed as http://mydomain.com/main.php?p=getstarted&c=foo&d=bar for getstarted and similarily for contactus. Instead of using this as the URL, I would like to use http://mydomain.com/getstarted, http://mydomain.com/getstarted/foo, or http://mydomain.com/getstarted/foo/bar. I have successfully implemented this by adding the the following to my Apache configuration file /etc/httpd/conf/httpd.conf as shown below (no need to check it out unless you want to). I wish to keep this functionality intact. <VirtualHost *:80> ServerName mydomain.com ServerAlias www.mydomain.com mail.mydomain.com smtp.mydomain.com ftp.mydomain.com DocumentRoot /var/www/html <IfModule mod_rewrite.c> RewriteLog /var/log/httpd/rewrite.log RewriteLogLevel 3 </IfModule> <Directory "/var/www/html"> Allow from all Options +Indexes <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / ## If the request is for a valid directory, file, or link, don't do anything RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule ^ - [L] #remove the trailing slash RewriteRule (.+)/$ $1 # If you add this first rule to support views, be sure to remove the QSA flag from the second rule (maybe not required since the first rule has the L flag) # replace my-page/my-controller/data with main.php?p=my-page&c=my-controller&data=data RewriteRule ^(getstarted|contactus)/([^/]+)/([^/]+)/?$ main.php?p=$1&c=$2&d=$3 [L,QSA] # replace my-page/my-controller with main.php?p=my-page&c=my-controller RewriteRule ^(getstarted|contactus)/([^/]+)/?$ main.php?p=$1&c=$2 [L,QSA] # replace my-page with main.php?p=my-page RewriteRule ^(getstarted|contactus)/?$ main.php?p=$1 [L,QSA] #Replaces file if "." is not in the string (i.e. it will not replace file.html, but will replace file RewriteRule ^([^.]+)$ $1.html [L] </IfModule> </Directory> </VirtualHost> Quote Link to comment https://forums.phpfreaks.com/topic/292405-how-to-structure-website-with-accompanied-microsites/ Share on other sites More sharing options...
QuickOldCar Posted November 11, 2014 Share Posted November 11, 2014 Using wildcard subdomains you can set it up any subdomain would work. If a folder was added then it would use from the folder. If you want to change subdomains on the fly you could do it all from the main site root www/index.php file with a controller...any other rules would like. Make database tables for each subdomain as needed. I'm heading out the door right now for the day, will explain it more when I can. Quote Link to comment https://forums.phpfreaks.com/topic/292405-how-to-structure-website-with-accompanied-microsites/#findComment-1496314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.