Co/sub-domains without rewritten URLs

Discussion in 'Tips/Tricks/Mods' started by sfrank, Feb 13, 2007.

  1. sfrank

    sfrank New Member

    Hi,
    I've recently overcome a much debated situation, I needed subdomain support without URL rewriting.

    For this example let's assume the site's primary domain is domain.tld and we'd like to create test.domain.tld with totally separate content.

    The standard ISPConfig way of sub-domain creation is as follows:
    - Add a new co-domain
    - Hit the Forward option and put a folder's name in there
    - Create the folder in the webroot

    With this setup, if you visit http://test.domain.tld you'll get served with the content of the desired folder, though the mod_rewrite operation takes place in a manner not hidden from the user so thus the address in the URL bar of the browser immediately switches to http://domain.tld/test to show the real path the content is coming from.

    This sometimes is not desirable, so I needed a "fix".
    Here it is:
    In /root/ispconfig/scripts/lib/config.lib.php at line 1368 remove the text [R].

    Explanation: The R flag tells mod_rewrite that when it applied the rewrite rule on the URL it shall not feed it to Apache "URL to file parsing" mechanism internally, but start a whole new request by rewriting the address in the user's browser and reloading it.

    Hope it helps some who wants to achieve the same behavior.

    I've got confirmation from Till that this modification does not break any part of the code, but you need to note that this solution is not upgrade persistent. This means that any time you upgrade ISPConfig this file might get overwritten.

    Furthermore as so many people would like to see this function added to ISPConfig, it'd be nice to somehow implement this one leaving the existing feature intact.

    A "Do you want rewritten URLs" checkbox on the Forward tab maybe?
     
  2. frk0r

    frk0r New Member

    i love you :p
     
  3. galaxyboss

    galaxyboss New Member

    is this effect all rewrite URL

    HI sfrank,

    is this modification will effect SEF modules such asin CMS(like joomla) and .htaccess if I want to use it?
    :eek:
     
  4. sfrank

    sfrank New Member

    I'm sorry but I've got no idea... All I cared was making sure no existing functionality in ISPConfig shall break. Maybe, if you could give me more details on what functionality you're fearing to get broken when you say .htaccess I might be able to answer it, but it's way to general like this.
     
  5. thecaptainjs

    thecaptainjs New Member

    Wow, you rock! I was looking for this!
     
  6. galaxyboss

    galaxyboss New Member

  7. thecaptainjs

    thecaptainjs New Member

    The point of this is to keep it all under the same website.

    Yea, creating a new website works fine, but not the way some of us want.
     
  8. thecaptainjs

    thecaptainjs New Member

    I noticed a problem. Now this could be with my install, but I have a subdomain setup (using this trick).

    There is an index.php there, and I get an internal server error unless I type in /index.php.

    And no, I dont have this problem any other times.
     
  9. falko

    falko Super Moderator ISPConfig Developer

    Maybe you must change a DirectoryIndex directive somewhere?
     
  10. PierreR32

    PierreR32 New Member

    Sorry i Have a question.

    by the code
    Code:
    ... "\nRewriteRule   ^/(.*)$  http://".$servername.$domain["domain_weiterleitung"]."$1  [R]";
    
    Must i Remove ONLY the PART with [R] or the complete Line ?

    Also this Part ?

    Code:
     $rewrite_rule .= "\nRewriteCond %{HTTP_HOST}   ^".$rewrite_cond_url." [NC]";
              if(substr($domain["domain_weiterleitung"],0,4) == "http" || substr($domain["domain_weiterleitung"],0,4) == "HTTP"){
                $domain["domain_weiterleitung"] = strtolower($domain["domain_weiterleitung"]);
                if(substr($domain["domain_weiterleitung"],-1) == "/") $domain["domain_weiterleitung"] = substr($domain["domain_weiterleitung"],0$
                $rewrite_rule .= "\nRewriteRule ^/(.*)         ".$domain["domain_weiterleitung"]."/$1 [L,R]";
              } else {
                //if(substr($domain["domain_weiterleitung"],-1) != "/") $domain["domain_weiterleitung"] .= "/";
                if(substr($domain["domain_weiterleitung"],0,1) != "/") $domain["domain_weiterleitung"] = "/".$domain["domain_weiterleitung"];
                $rewrite_rule .= "\nRewriteRule   ^/(.*)$  http://".$servername.$domain["domain_weiterleitung"]."$1  [R]";
    Thx for Help.

    Greetz Pierre
     
  11. andrusha

    andrusha New Member

    can someone help which line to comment out????
     
  12. falko

    falko Super Moderator ISPConfig Developer

    Ehm, what exactly is your problem?
     
  13. andrusha

    andrusha New Member

    i figured out thank you .....
     
  14. schmidtedv

    schmidtedv New Member

    I did this by patching line 1410 in ISPConfig 2.2.24...works nicely.

    However, there seems to be a little sideeffect:

    Error-Pages are not shown anymore for these subdomains. If I just try to get a non-existant-link, I only get the standard error-page from IE. It doesn't matter to take my own error-pages or the once that come with ISPConfig. So this seems to be a little disadvantage with this patch...
     
  15. DUCKFACE

    DUCKFACE New Member

    prob

    okey ... i made the changes ..
    the index.php is visible and url is a.sometnin.com

    but .. when i watn to procede with anotehr page .. i got this ..

    Not Found

    The requested URL /page.php was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    what gets wrong ..

    isp is 2.2.32
    ________
    VIDEOS PORNOS
    ________
    LIST OF MAZDA FACILITIES PICTURE
     
    Last edited: Mar 17, 2011
  16. falko

    falko Super Moderator ISPConfig Developer

    What exactly do you want to achieve, and what have you done so far?
     
  17. DUCKFACE

    DUCKFACE New Member

    for now ..

    http://a.sometni.com to looks like a.sopmetni.com not like sometnin.com/a/

    when i
    "\nRewriteRule ^/(.*)$ http://".$servername.$domain["domain_weiterleitung"]."$1 [R]";
    remove the - [R] in the address bar address is visible like i want - s.sometin.com
    but ... the links between files r missing
    for example when i browsing the pages when [R] is there .. i can open page1.php from page.php .
    but when [R] is removed -> page1.php gets 404 page not found
    ________
    Buy no2 vaporizer
     
    Last edited: Mar 12, 2011
  18. DUCKFACE

    DUCKFACE New Member

    Last edited: May 12, 2011
  19. t-mug

    t-mug New Member

    2 thoughts on this

    1.) First thing is: I have had run webs in such pseudo subdomains (by [R]-deletion-hack) without errors. But I had always to inject an apache directive into this kind of co-subby-domain-thingy like "RewriteBase /" (written into .htaccess). A CMS like e. g. Drupal runs this way without problems.

    2.) The summary for me is that this is a bad replacement for real Apache subdomains, which can have always an own DOCUMENT_ROOT, own statistics etc. - However, good news: there is a way to hand real Apache subdomains to customers! How? Let them be resellers!. You can this way control:
    1. how many "webs" (= subdomains) customers may have, e. g. "3"
    2. how many domains customers may have, e. g. "1"
    3. how many diskspace of the "reseller" space a web/subdomain may have, e. g. 500MB of "resellers" 2GB total;
    4. if or if not an customer is allowed to inject own apache directives (surely not recommended)
    5. that the customer may not edit DNS resords.
    Thats a lot! An almost perfect solution. Except maybe: some irritations based on hardcoded naming conventions, like the term "Reseller" or "Customers" inside the navigation.

    Anyway, whatever works ...
     

Share This Page