![]() |
How to configure a copy of Codeigniter website on a subdomain? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to configure a copy of Codeigniter website on a subdomain? (/showthread.php?tid=74238) |
How to configure a copy of Codeigniter website on a subdomain? - einav - 09-01-2019 I want to create a testing environment for my working Codeigniter (version 3.1.9) website. It should be an exact replica of my original website, where I can modify the code and test changes before uploading them to the real website. I thought I'd do it using a subdomain on my main domain. I set the subdomain (test.mydoaim.com) through cPanel, and copied all the code files to the relevant directory. Now, when I go to test.mydomain.com, or to test.mydomain.com/controller_name, it all works well, but when I try any inner links (such as test.mydomain.com/controller_name/anything), I get nothing on Firefox, or this error message on Chrome: Quote:This page isn’t working I'm guessing this is an htaccess issue? or a routing issue? Any pointers on how to make this work would be highly appreciated! My config/routes.php file is quite simple: PHP Code: $route['default_controller'] = 'website'; And this is my htacces file: Code: RewriteOptions inherit RE: How to configure a copy of Codeigniter website on a subdomain? - virtualgadjo - 09-01-2019 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 RE: How to configure a copy of Codeigniter website on a subdomain? - dave friend - 09-01-2019 Have you set $config['base_url'] to reflect the subdomain, e.g. PHP Code: $config['base_url'] = 'https://www.test.mydomain.com'; RE: How to configure a copy of Codeigniter website on a subdomain? - einav - 09-01-2019 (09-01-2019, 05:09 AM)dave friend Wrote: Have you set $config['base_url'] to reflect the subdomain, e.g. 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://"; (09-01-2019, 03:30 AM)virtualgadjo Wrote: Hi,Hi, I tried removing the www, and I narrowed my htaccess file to just: Code: [php]RewriteEngine On But the results are the same ![]() 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! |