Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Building a system to easily manage 100's of sites

My very first steps towards multi-tenancy

     
3:21 pm on Aug 28, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2003
posts: 1550
votes: 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)?
  • 3:52 pm on Aug 28, 2013 (gmt 0)

    Senior Member

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

    joined:Mar 15, 2002
    posts:6807
    votes: 0


    I assume duplicate content is not a concern?
    3:57 pm on Aug 28, 2013 (gmt 0)

    Senior Member

    WebmasterWorld Senior Member 10+ Year Member

    joined:Mar 14, 2003
    posts: 1550
    votes: 0


    Hi DrDoc, no it isn't, those pages would be hidden from SE and the site would have more "unique" pages.
    12:40 am on Aug 29, 2013 (gmt 0)

    Senior Member

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

    joined:Mar 15, 2002
    posts:6807
    votes: 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.
    2:00 am on Aug 29, 2013 (gmt 0)

    Administrator

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

    joined:Aug 10, 2004
    posts:10544
    votes: 8


    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.
    7:22 am on Aug 29, 2013 (gmt 0)

    Senior Member

    WebmasterWorld Senior Member 10+ Year Member

    joined:Mar 14, 2003
    posts: 1550
    votes: 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
    7:45 am on Aug 29, 2013 (gmt 0)

    Administrator

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

    joined:Aug 10, 2004
    posts:10544
    votes: 8


    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/
    8:10 am on Aug 29, 2013 (gmt 0)

    Senior Member

    WebmasterWorld Senior Member 10+ Year Member

    joined:Mar 14, 2003
    posts: 1550
    votes: 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]
    8:22 am on Aug 29, 2013 (gmt 0)

    Administrator

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

    joined:Aug 10, 2004
    posts:10544
    votes: 8


    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=
    8:27 am on Aug 29, 2013 (gmt 0)

    Senior Member

    WebmasterWorld Senior Member 10+ Year Member

    joined:Mar 14, 2003
    posts: 1550
    votes: 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.
     

    Join The Conversation

    Moderators and Top Contributors

    Hot Threads This Week

    Featured Threads

    Free SEO Tools

    Hire Expert Members