homepage Welcome to WebmasterWorld Guest from 54.197.15.196
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Building a system to easily manage 100's of sites
My very first steps towards multi-tenancy
le_gber

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4605453 posted 3:21 pm on Aug 28, 2013 (gmt 0)

Hi guys,

I am currently tinkering with the following idea:

  • I want to create a "core" site with a dozen pages that can be re-purposed and customized.

    For each re-purposed site I am then thinking of including or requiring the page dynamically if a local copy of the page doesn't exist.

    The url would look like:
    www.repurposed.com/index.php?dir=about&page=index

    if local /about/index.php file doesn't exists
    include core file
    if local /about/index.php file exists
    include local copy

    (openbasedir and proper validation of the $dir and $page using switch(){case:} is assumed)


  • Following on that idea, I also thought of doing a php include in the .js file for script used across all those sites (like carousel) using something like:


    <FilesMatch "\.(js)$">
    SetHandler application/x-httpd-php
    </FilesMatch>

    Do you guys see any reasons why I shouldn't do any of the above? Any flaws in my plan? Should I use a database instead to hold all the files? Am I right in thinking that including files is faster and put less stress on the server (but maybe not safer)?

  •  

    DrDoc

    WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member



     
    Msg#: 4605453 posted 3:52 pm on Aug 28, 2013 (gmt 0)

    I assume duplicate content is not a concern?

    le_gber

    WebmasterWorld Senior Member 10+ Year Member



     
    Msg#: 4605453 posted 3:57 pm on Aug 28, 2013 (gmt 0)

    Hi DrDoc, no it isn't, those pages would be hidden from SE and the site would have more "unique" pages.

    DrDoc

    WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member



     
    Msg#: 4605453 posted 12:40 am on Aug 29, 2013 (gmt 0)

    Personally, I'm a proponent for database driven sites. But redirects would work as well ... You can simply check if the file exists (
    -f), or else load a different file internally.

    I've done that on image servers to load a "no-image" image.

    phranque

    WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



     
    Msg#: 4605453 posted 2:00 am on Aug 29, 2013 (gmt 0)

    if your solution is to have the php script do a HTTP GET Request to gather content for your reponse, that's going to be slow for the visitor.

    a file include should be no problem.

    le_gber

    WebmasterWorld Senior Member 10+ Year Member



     
    Msg#: 4605453 posted 7:22 am on Aug 29, 2013 (gmt 0)

    @DrDoc, by doing a file exist (-f) do you mean in htaccess rather than PHP?
    @phranque, the HTTP GET is only used to know which page to serve, does this still slow things down? I was thinking of mode_rewriting everything to make the URL look nicer like:

    www.repurposed.com/index.php?dir=about&page=index
    to
    www.repurposed.com/about/index.php

    phranque

    WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



     
    Msg#: 4605453 posted 7:45 am on Aug 29, 2013 (gmt 0)

    the HTTP GET is only used to know which page to serve, does this still slow things down?

    if your php script is doing a separate roundtrip to another server before responding, yes.


    www.repurposed.com/about/index.php

    use the DIrectoryIndex directive to set the default directory index document to index.php and use this url instead:
    www.repurposed.com/about/
    le_gber

    WebmasterWorld Senior Member 10+ Year Member



     
    Msg#: 4605453 posted 8:10 am on Aug 29, 2013 (gmt 0)

    if your php script is doing a separate roundtrip to another server before responding, yes.
    - it wouldn't, the "core" site and the "repurposed" site would be reference with paths from Apache /home/

    use the DIrectoryIndex directive to set the default directory index document to index.php and use this url instead:
    www.repurposed.com/about/


    that's my rewrite at the moment, will it simply ignore the second variable if not defined?

    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)\.htm$ /index.php?section=$1&amp;page=$2 [L]

    phranque

    WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



     
    Msg#: 4605453 posted 8:22 am on Aug 29, 2013 (gmt 0)

    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)\.htm$ /index.php?section=$1&amp;page=$2 [L]


    you don't need to use an html entity for anything in the url here.
    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)\.htm$ /index.php?section=$1&page=$2 [L]



    the only way to match the pattern and get an undefined $2 is to request something like:
    www.example.com/something/.htm

    but yes - that would internally rewrite to:
    /index.php?section=something&page=

    le_gber

    WebmasterWorld Senior Member 10+ Year Member



     
    Msg#: 4605453 posted 8:27 am on Aug 29, 2013 (gmt 0)

    ha, yes I forgot, I was trying to "hide" PHP by having .htm extensions and enabling PHP to run on htm files :)

    Thanks for your help.

    Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved