Welcome Guest, Not a member yet? Register   Sign In
How to configure a copy of Codeigniter website on a subdomain?
#4

(This post was last modified: 09-01-2019, 06:18 AM by einav.)

(09-01-2019, 05:09 AM)dave friend Wrote: Have you set $config['base_url'] to reflect the subdomain, e.g.

PHP Code:
$config['base_url'] = 'https://www.test.mydomain.com'

My base_url seems to be configured OK, since I am able to access  test.mydomain.com, or test.mydomain.com/controller_name.
Its only the inner pages, such as test.mydomain.com/controller_name/anything that cause an error.

This is how my base_url is configured, under config/config.php:
PHP Code:
$protocol is_https() ? "https://" "http://";
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "";

if(
is_cli()){
  $config['base_url'] = '';
}

elseif(
stristr($host"localhost") !== FALSE || (stristr($host'192.168.') !== FALSE) || (stristr($host'10.0.2.2') !== FALSE)){
  $config['base_url'] = $protocol $host "/pi/";
}

else{
    $allowed_hosts = ['mydomain.tld''www.mydomain.tld','anotherdomain.tld','www.test.mydomain.tld'];

    $config['base_url'] = in_array($host$allowed_hosts) ? $protocol.$host."/" "we-do-not-recognise-this-host.com";


(09-01-2019, 03:30 AM)virtualgadjo Wrote: Hi,
imho, first thing to check, if you set your subdomain as test.domain.com, try to access... test.domain.com without the www which means: comment those two lines
<code>
RewriteCond %{HTTP_HOST}(.*) !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R,L]
</code>
in your htaccess file with an #

second thing i would suggest if this subdomain is a test one, but you may already have done this, create a dedicated db for the subdomain else whatever you change in the db will appear on the production domain too...

hope it helps
have a nice day
Hi,

I tried removing the www, and I narrowed my htaccess file to just:
Code:
[php]RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L][/php]


But the results are the same Sad 

And yes, I did set up a duplicate db for testing purposes. But that's a good pointer. I t would be a shame to mess up the real db!
Reply


Messages In This Thread
RE: How to configure a copy of Codeigniter website on a subdomain? - by einav - 09-01-2019, 05:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB