CodeIgniter Forums
Problem when running my app with a different base URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Problem when running my app with a different base URL (/showthread.php?tid=75836)



Problem when running my app with a different base URL - Umar - 03-22-2020

Hello everyone,

I have just started to learn CodeIgniter 4 and I have gone through the online documentation.
I am using the local development server that comes with CodeIgniter 4 to host my web app locally.
I have also set the variable CI_ENVIRONEMENT in my .env file to development.

Following the documentation, I have set my base URL to "http://tutorial.ci/" in the file app/Config/App.php and also within the .env file, the baseURL has been set as app.baseURL="http://tutorial.ci/".
Note that I have uncommented the app.baseURL line.

So my first question is, after launching the server, why does the server is still starting on http://localhost:8080 despite modifying the baseURL?

And my second question is, why can't I access the web app in my browser via the link "http://tutorial.ci/"?

Kindly find as attachement of the  .env and app/Config/App.php files.
I will be very grateful if someone could help me to solve this issue as I am a complete novice to CodeIgniter.  Smile
Thanks in advance

Best Regards,
Umar


RE: Problem when running my app with a different base URL - InsiteFX - 03-22-2020

If you want to run with a base url like that then you need to use vhosts file.

Which is under Apache server.

Code:
#--------------------------------------------------------------
# HTTP:
#--------------------------------------------------------------
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/your_project_root_folder"
    ServerName tutorial.ci
    ServerAlias tutorial.ci
    <Directory "C:/xampp/htdocs/your_project_root_folder">
        Order allow,deny
        Allow from all
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
 
Your vhost would like something like that.

If you are on Windows you need to edit the windows hosts file.

C:\Windows\System32\drivers\etc\hosts

Using notepad and add this.

127.0.0.1    tutorial.ci
or (IP verison 6)
::1    tutorial.ci

You should install either WAMP or XAMPP depending on your needs.


RE: Problem when running my app with a different base URL - Umar - 03-28-2020

Hello,
Thanks for the reply.
I have followed the instructions that you have given as well as an online tutorial on how to setup a Virtual Host in Windows: https://ultimatefosters.com/hosting/setup-a-virtual-host-in-windows-with-xampp-server/

Despite all of these, the page Index of/ is appearing when I launch the link www.tutorial.ci

Kindly find as attachements the host, http.conf, httpd-vhosts.conf files which I have modified.
Could you please advice?
Thanks in advance