1
tzvook
sub-domains for modules
  • 2008/5/9 18:31

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


I'm trying to lead my subdomains into XOOPS modules, but when using the "sub" adress ( IE: "the-module.my-site.com") all I get is this:
Selected module does not exist!

though the adress is leading to "my-site.com/modules/the-module"


before I'll begin digging the core, I simply want to know if somebody had this issue and if there is a simple solution for that (or any direction to lead me to)

2
tzvook
Re: sub-domains for modules
  • 2008/5/9 19:03

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


O.K. found it, at least one place that cause it ...

index.php
$xoopsModule =& $module_handler->getByDirname($xoopsConfig['startpage']);


the "getByDirname" probably is the cause, and I wonder how to bypass it without security risks

I found some threads about it:
https://xoops.org/modules/newbb/viewtopic.php?topic_id=44326&forum=7&post_id=229675#forumpost229675

but it's not the answere, since the the solution is just a redirect ...

3
trabis
Re: sub-domains for modules
  • 2008/5/9 21:14

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


If you are pointing to: "my-site.com/modules/the-module" how do you end up at index.php?
Another problem is relative url.
When a module tries to include ../../mainfile.php it will give a NOT FOUND error. I think there is no easy way of doing this.

4
seolio
Re: sub-domains for modules
  • 2008/5/9 23:15

  • seolio

  • Not too shy to talk

  • Posts: 196

  • Since: 2005/11/2


It may not be exactly what you are looking for, probably not what you are looking for; but can you not just use .htaccess mod rewrite?

5
tzvook
Re: sub-domains for modules
  • 2008/5/10 0:31

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


Quote:

seolio wrote:
It may not be exactly what you are looking for, probably not what you are looking for; but can you not just use .htaccess mod rewrite?


I don't mind using mod-rewrite, but I think XOOPS will behave the same ...

6
seolio
Re: sub-domains for modules
  • 2008/5/10 1:07

  • seolio

  • Not too shy to talk

  • Posts: 196

  • Since: 2005/11/2


Maybe, it really is a tough one, and I am no expert on PHP so I will not even go into that, I just thought mod rewrite may help as that is what I use, could be worth a try just to see if you can get it to behave?

As I said I am no expert, just trying to help the best I can

7
peterr
Re: sub-domains for modules
  • 2008/5/10 6:52

  • peterr

  • Just can't stay away

  • Posts: 518

  • Since: 2004/8/5 9


Quote:

tzvook wrote:
I'm trying to lead my subdomains into XOOPS modules, but when using the "sub" adress ( IE: "the-module.my-site.com") all I get is this:
Selected module does not exist!

though the adress is leading to "my-site.com/modules/the-module"


It seems to be going against the standard 'structure' of sub-domains ??

If there is a subdomain calledhttp://the-module.my-site.com , then the web root ishttp://my-site.com , and the path structure will be something like ..

/home/username/public_html/ for web root
/home/username/public_html/the-module/ for subdomain

and the path 'modules', for std XOOPS sites will be ..

/home/username/public_html/modules/

which is the same level as the subdomain, unfortunately.

If you can (somehow) point your subdomain to ..

/home/username/public_html/modules/the-module/

that might work, but that is not how Apache, etc, views a subdomain.
NO to the Microsoft Office format as an ISO standard.
Sign the petition

8
tzvook
Re: sub-domains for modules
  • 2008/5/10 7:20

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


10x all for reply
I'm afraid you miss the point:
I did lead Apache to pointhttp://sub.domain.com tohttp://www.domain.com/modules/sub .

I get to the right place ... but I get this massage since XOOPS is defined to "know" "what module" + "module permition" by parts of the url .

I think the only "good way" to bypass this is using rewrite rules, but I still havn't done it right !!

JIJOE's post @ PEAK XOOPS supply a clue ... but not exactly what I need ...
His simple solution for turning "/modules/" into "/md/" is elegant and very nice ... needs a rewrite expert to turn it to my needs

9
peterr
Re: sub-domains for modules
  • 2008/5/10 7:52

  • peterr

  • Just can't stay away

  • Posts: 518

  • Since: 2004/8/5 9


You may wish to consider modifying mainfile.php , to look for the subdomains. There are various PHP variables that could be used, as they are changed when a subdomain is used. For example ..

If I understand how you have the subdomain setup with Apache, then these PHP variables should be present ..

Quote:

_SERVER["DOCUMENT_ROOT"] /home/username/public_html/modules/sub
_SERVER["HTTP_HOST"] sub.domain.com
_SERVER["SERVER_NAME"] sub.domain.com
_ENV["DOCUMENT_ROOT"] /home/username/public_html/modules/sub
_ENV["HTTP_HOST"] sub.domain.com
_ENV["SERVER_NAME"] sub.domain.com


Some possible mainfile.php changes ..

if $_SERVER["HTTP_HOST"] == sub.domain.com {
    
define('XOOPS_ROOT_PATH''/home/username/public_html/modules/sub');
    
define('XOOPS_URL''http://sub.domain.com');

} else {
    
define('XOOPS_ROOT_PATH''/home/username/public_html');
    
define('XOOPS_URL''http://domain.com');
}


but, no doubt you have already tried that, or there are other implications ??
NO to the Microsoft Office format as an ISO standard.
Sign the petition

10
tzvook
Re: sub-domains for modules
  • 2008/5/13 19:49

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


Quote:

peterr wrote:

Some possible mainfile.php changes ..

if $_SERVER["HTTP_HOST"] == sub.domain.com {
    
define('XOOPS_ROOT_PATH''/home/username/public_html/modules/sub');
    
define('XOOPS_URL''http://sub.domain.com');

} else {
    
define('XOOPS_ROOT_PATH''/home/username/public_html');
    
define('XOOPS_URL''http://domain.com');
}


but, no doubt you have already tried that, or there are other implications ??


10X peterr
This can't be done since I am generating subdomains automatically with this "mod_rewrite" rules:
Options +FollowSymLinks
rewriteEngine on
# Internally rewrite <subdomain>.mydomain.com/<URLpath> to inthetube.info/subs/<subdomain>/<URLpath>
rewriteCond $!^modules/
rewriteCond %{HTTP_HOST} !^www.mydomain.com
rewriteCond 
%{HTTP_HOST} ^([^.]+).mydomain.com
rewriteRule 
(.*) /modules/%1/$

rewriteCond 
%{THE_REQUEST} ^[A-Z]{3,9} /modules/
rewriteRule ^modules/([^/]+)/(.*)$ http://$1.mydomain.com/$1 [R=301,L]


I do that in the httpd.conf (not .htaccess), and it automatically leads sub-domain.mydomain.com to mydomain.com/modules/sub-domain

What you suggested will make the sub-domain into the XOOPS root

I'm trying to make JIJOE's code fit my needs, but for now with no sucsess
// modules changer (insert this 8 lines)
    
if( ! function_exists'modules_changer' ) ) {
        
$_SERVER['REQUEST_URI'] = str_replace'bridge.mydomain.com' 'www.mydomain.com/modules/bridge' , @$_SERVER['REQUEST_URI'] ) ;
        
$_SERVER['HTTP_REFERER'] = str_replace'bridge.mydomain.com' 'www.mydomain.com/modules/bridge' , @$_SERVER['HTTP_REFERER'] ) ;
        function 
modules_changer$s ) {
            return 
str_replace'www.mydomain.com/modules/bridge' 'bridge.mydomain.com' $s ) ;
        }
        
ob_start'modules_changer' ) ;
    }


@ the begining of mainfile.php

Login

Who's Online

168 user(s) are online (115 user(s) are browsing Support Forums)


Members: 0


Guests: 168


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits