How to perfectly set up virtual host for codeigniter project? How to perfectly set up virtual host for codeigniter project? codeigniter codeigniter

How to perfectly set up virtual host for codeigniter project?


I am on windows 10 and I use xampp with virtual host this is way I set up.

Put forward slash at end of base url

$config['base_url'] = 'http://dev.facebook-login.com/';

First go to

Windows > System32 > drivers > etc > host

You may need to open as administrator to be able to save it

You might see some thing like

127.0.0.1       localhost 

Below that create another one for dev.facebook-login.com like example:

127.0.0.1       localhost127.0.0.1       dev.facebook-login.com

Save it

Then go to the

xampp > apache > conf > extra > httpd-vhosts.conf

open it as administrator so you can save it.

No need for the index.php on DocumentRoot

<VirtualHost *:80>    ##ServerAdmin webmaster@dummy-host.example.com    DocumentRoot "C:/xampp/htdocs/CI_projects/facebook-login"    ServerName dev.facebook-login.com    ##ServerAlias www.dummy-host.example.com    ##ErrorLog "logs/dummy-host.example.com-error.log"    ##CustomLog "logs/dummy-host.example.com-access.log" common</VirtualHost> 

Save it and restart the severs.

I use this for my htaccess

Options +FollowSymLinksOptions -IndexesDirectoryIndex index.phpRewriteEngine onRewriteCond $1 !^(index\.php|images|robots\.txt)RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php/$1 [L,QSA]


httpd-vhosts.conf

Listen 1122<VirtualHost *:1122>DocumentRoot "D:\laragon_server\www\hugpong_production"<Directory "D:\laragon_server\www\hugpong_production">Order allow,denyAllow from all</Directory></VirtualHost>

.htaccess

<IfModule mod_rewrite.c>RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php?/$1 [L]</IfModule>


https://www.namecheap.com/support/knowledgebase/article.aspx/10026/33/installing-an-ssl-certificate-on-xampp/php 8 is not ready for CI4 as of jan 2021!XAMPP has preloaded ssl certificate in php 7 packagesconsider uncommon vhosts extra and place this in itmy only persistent issues is codeigniter 4 routes, have to turn on php spark serve to get XAMPP to route pages outside of default index, nothing else works, its garbage to that extent, will try with composer next....a whole book needsto be wrote about codeigniter 4 routes and why they don't work, 200 pages plus

<VirtualHost localhost *:80>DocumentRoot "C:\xampp\htdocs"ServerName localhost

<VirtualHost example.com *:8080>     ServerName example.com     ServerAlias www.example.com     DocumentRoot "C:\xampp\htdocs\codeignite4\public"   //my project folder is codeignite4 without using composer this time   //i added listen 8080 under listen 80 in htppd.conf    ServerName example.com  

<VirtualHost truservex.com *:443>DocumentRoot "C:\xampp\htdocs\codeignite4\public"ServerName example.comSSLEngine OnSSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"// you can verifiy these file locations, certificate dataSSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"// going without the Directory tag can be helpful to drop in vhosts<Directory "C:\xampp\htdocs\codeignite4\public">Require all granted

doing this i was able to replicate the original install, create site accessusing http://localhost:8080 or http://example.com/ as my base urlin my example index.php is removed, set to ''when using command prompt to get into codeignite4 project folder i canlaunch php spark serve and routes will work that were previously 404