munsiem Posted July 18, 2011 Share Posted July 18, 2011 Hey everyone, I have a question (it's a crazy one) and am hoping to hear some feedback on what I have been developing. Many common MVC frameworks require you to place your website in the root directory of your htdocs folder. If you wanted to add another website (example being maybe a mobile version), you would have to create a sub domain or use clever naming conventions in the controllers and views. I wanted to try and create a way in which I did not have to create a sub domain each time I wanted to create a new site - rather simply just create a new folder and the framework reside and hold multiple applications. So, the biggest issue is handling the paths of images and front end scripts. Every application has its very own public folder. Before I was used to having everything absolute so you would see: /app/default/public/img/tedd.jpg Well when you have multiple sites and applications you end up seeing this: /site1/app/default/public/img/test.jpg /site1/app2/default/public/img/test.jpg Now when you upload that to your server you are going to have to change the paths of all the images and scripts (because surely you wouldn't want to have to create site1 on your server if it's the only site there). Well I decided to test out an interesting way to access the applications public folder by modifying the htaccess folder. So now instead of writing out this absolute path, I would simply say: _public/img/test.jpg And that would reference the public folder of the application of which you are viewing. I did this so I could have multiple websites on my server without having to create a subdomain each time (especially since mine limits me - shared hosting lol). That's the basic concept and it's achieved by using the <BASE> tag and getting the directory of which the index.php file lyes in (making this the new root folder). Do you think this is overkill or perhaps something quite interesting? Just wondering because sometimes as a developer you will come across some really crazy ideas and they can either be completely innovative or simply overkill. Here's an example of what I had to do in the .htaccess file: ### CSS RULES ### RewriteRule ^(.*)/_public/css/_public/(.*)$ apps/$1/_public/$2 [L] RewriteRule ^(.*)_public/css/_public/(.*)$ apps/_default/_public/$2 [L] ### REGULAR RULES ### RewriteRule ^(.*)/_public/(.*)$ apps/$1/_public/$2 [L] RewriteRule ^_public/(.*)$ apps/_default/_public/$1 [L] RewriteRule ^(.*)/vendors/(.*)$ vendors/$2 [L] Thanks and any advice would be nice. Keep in mind my main goal is to have multiple sites in a directory without having to create a subdomain each time. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/242239-mvc-framework-in-subdirectories/ Share on other sites More sharing options...
phpSensei Posted July 21, 2011 Share Posted July 21, 2011 I dont see why you would have to create a new sub domain regardless of any mvc framework. Quote Link to comment https://forums.phpfreaks.com/topic/242239-mvc-framework-in-subdirectories/#findComment-1245794 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.