Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Subdomains
#11

[eluser]Maglok[/eluser]
Yeah I am already using robots.txt to permanently block the test sub from searchengines. The rest of the site is temporarily blocked till it launches. a 302 redirect is a good idea. Thanks. Smile

EDIT: Well I have managed to make it work in part.

If I go to test.domain.com/sub1 (cause I want to work with the test environ for a sec) then my base_url is test.domain.com/sub1. So that's working. All the site_url() functions generate stuff like test.domain.com/sub1/news

The issue is, that those controllers are obviously not there, meh. So all links are dead (as are pictures, but I could move those while I can't move the controllers (or intend to).
#12

[eluser]Maglok[/eluser]
Here is an update. Have been trying to get it to work for some time. Bear with me this is a bit of explaining.

Code:
./
./index.php (Is the production environment)
./system (Production environment)
./subdomain1/index.php (Goes to the production environment)
./subdomain2/index.php (Goes to the production environment)
./test/index.php (Is the test environment)
./test/system (Test environment)
./test/subdomain1/index.php (Goes to the test environment)
./test/subdomain2/index.php (Goes to the test environment)

Ignore the production environment for now. I am working on the test environment.

Each of the index.php's has the following globals defined:
Code:
/*
|---------------------------------------------------------------
| APP SPECIFIC
|---------------------------------------------------------------
|
| Set the base_url and site template
|
*/

    define('PHPLARP_SITE', 'sub1');
    define('PHPLARP_BASE', 'test.domain.nl/subdomain1');

Also in my config.php I indeed set up the base_url change:
Code:
$config['base_url']    = "http://" . (defined('PHPLARP_BASE')?PHPLARP_BASE:"") . "/";

If I now approach test.domain.nl/subdomain1 it loads the entrance page correctly, showing me my news. The links generated through site_url() are now indeed test.domain.nl/subdomain1/stuff. The problem is that it does not parse that correctly. Once I try to go from the welcome page I get a 404.

I figured mabye something to do with the .htaccess and the removing of the index.php. If I try to go to: http://test.domain/subdomain1/index.php/someclass I get a "No input file specified."

If I use the .htaccess I also use for the main domain I get routed to the main domain. This is that .htaccess (I hate htaccess!):
Code:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|flash|images|css|xml|subdomain1|subdomain2|scripts|favicon\.ico)
RewriteRule ^(.*)$ ./index.php?/$1 [L]

I am pretty much stumped why the app doesn't accept any controllers/methods, cause it should. It probably has to do with the .htaccess, but I have been unable to nail it.
#13

[eluser]rogierb[/eluser]
RewriteBase /subdomain1/
RewriteBase /subdomain2/
RewriteBase / => main site

If I understood corerctly, that should do it.
#14

[eluser]Maglok[/eluser]
I can't believe it was that easy. Shows you how 'good' I understand .htaccess. You saved my day, it works. Thanks. Smile
#15

[eluser]yabdab[/eluser]
I am writing an app with a similar issue.

Subscribers using my app will have their own custom URL, user1.domain.com

So if I understand correctly, then I would do this in the index file...

Code:
define('YD_BASE', 'user1');

then this in the config file...

Code:
$config['base_url']    = "http://" . (defined('YD_BASE')?YD_BASE:"www") . ".domain.com/";

I do not use sub folders as the original author does, just need to grab the host from the URL and use it to display the correct data.

Can also then confirm that YD_BASE constant will be available throughout the rest of the CI app pages?




Theme © iAndrew 2016 - Forum software by © MyBB