set up multiple applications |
Hi,
Here's my context : codeigniter 3 on wamp. Here's my problem :
I want to run my applications by using the following url : http://localhost/<application_name>_<environment> I don't succeed in making the access to my application work ("I've got The requested URL was not found on this server"). I'm lost in the configuration of index.php, .htaccess, routes.php, config.php In index.php, I parse $_SERVER['REQUEST_URI'] to set $application_folder value and database credentials In .htaccess i set : Code: <IfModule mod_rewrite.c> in config.php I set : Code: $config['base_url'] = 'http://localhost'; and $config['index_page'] = ''; Did I make the good choices for my source tree ? How should I configure the files index.php, .htaccess, routes.php, config.php ? Please help me
Hi,
I tried that : In my htaccess located in code_igniter directory : Code: <IfModule mod_rewrite.c> In route.php in /code_igniter/applications/generic_test/config : Code: $route['default_controller'] = 'generic_controller'; In config.php in /code_igniter/applications/generic_test/config : Code: $config['base_url'] = 'http://localhost/code_igniter'; In index.php in code_igniter directory : Code: $application_folder = 'applications/generic_test'; When I run http://localhost/application1/test I've got "The requested URL /application1/test was not found on this server". I checked my rewrite rule on a the site https://htaccess.madewithlove.be/ and "http://localhost/application1/test" should produce "http://localhost/code_igniter/generic_test.php/generic_controller" So I don't understand what's wrong. Thanks for your help
@fredg,
Why didn't you just use the built in CI environment feature: https://codeigniter.com/user_guide/gener...ments.html This way, by simply changing the value of a variable your code will work in multiple environments.
Are there any reason you need to do it like that? Because that just look like you are going to dig a big hole in the ground and never get out of it.
I would recommend setting up virtual hosts (multiple domains) and send environment variables from apache into CI. And change your application directory path. So you can access it normally. (01-16-2020, 11:43 AM)php_rocs Wrote: @fredg,Hi, Thanks for your reply. Here is a part of the document https://codeigniter.com/user_guide/gener...ments.html "Developers often desire different system behavior depending on whether an application is running in a development or production environment. For example, verbose error output is something that would be useful while developing an application, but it may also pose a security issue when “live”." That doesn't meet my need because my code is different following I'm on test or production. I want to switch for code test or code prod following my url (01-16-2020, 11:49 AM)jreklund Wrote: Are there any reason you need to do it like that? Because that just look like you are going to dig a big hole in the ground and never get out of it.Hi, Thanks for your reply. Here's my need : I need to run my test code if my url contains "test" I need to run my prod code if my url contains "prod" I need to run my code with database application1 id my url contains "application1" I need to run my code with database application2 id my url contains "application2" I don't know If I followed the good way, that's why I asked if someone could help me. I would recommend setting up virtual hosts (multiple domains) and send environment variables from apache into CI. => Thanks I'm going to investigate further on that point And change your application directory path. So you can access it normally. => Done by using two index files (01-16-2020, 11:49 AM)jreklund Wrote: Are there any reason you need to do it like that? Because that just look like you are going to dig a big hole in the ground and never get out of it. The document https://codeigniter.com/user_guide/gener..._apps.html describes the configuration I set, but things are missing about htaccess, routes.php, config.php, (01-16-2020, 11:49 AM)jreklund Wrote: Are there any reason you need to do it like that? Because that just look like you are going to dig a big hole in the ground and never get out of it. Hi, I found the solution to my problem. The main problem was that I had two index.php (one in code_igniter directory and one in each application directory) and I modified the bad one (the one in code_igniter directory). I used virtuel hosts, as you adviced to me to do, to shorten my urls Thank you for your help. Frederic |
Welcome Guest, Not a member yet? Register Sign In |