Build your first application - 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: Build your first application (/showthread.php?tid=77200) Pages:
1
2
|
Build your first application - pdos - 07-31-2020 While following the Build the first application -> https://codeigniter.com/user_guide/tutorial/static_pages.html --Static pages. Behavior is different then what is documented: localhost:8080/pagesĀ --> http://localhost/ci-news/public/ For each URL listed in Documentation, I have to specify public otherwise it doesn't work. How to remove the requirement to always put public in for the documentation to work? **Not executing php spark serve as I am running xampp. Files are located under /htdocs/ci-news. Moreover, as soon as I add the routesĀ $routes->get('(:any)', 'Pages::view/$1'); in app/Config/Routes.php it starts giving the 404 not found errors. ----Pages controller------ <?php namespace App\Controllers; use CodeIgniter\Controller; class Pages extends Controller { public function index() { return view('welcome_message'); } public function view($page = 'home') { if ( ! is_file(APPPATH.'/Views/pages/'.$page.'.php')) { // Whoops, we don't have a page for that! throw new \CodeIgniter\Exceptions\PageNotFoundException($page); } $data['title'] = ucfirst($page); // Capitalize the first letter echo view('templates/header', $data); echo view('pages/'.$page, $data); echo view('templates/footer', $data); } } ------------------- Thanks, RE: Build your first application - jreklund - 08-01-2020 You need to set-up something called "virtual host" to get rid of /public/ in your url. https://www.cloudways.com/blog/configure-virtual-host-on-windows-10-for-wordpress/ Document root in the tutorial above are your public folder. RE: Build your first application - pdos - 08-01-2020 That helped a little. Changed the following as per the article: httpd-vhosts.conf: <VirtualHost *:80> DocumentRoot "c:/xampp/htdocs/ci-news/public" ServerName localhost/ <Directory "c:/xampp/htdocs/ci-news/public"> </Directory> </VirtualHost> and drivers/etc/hosts 127.0.0.1 localhost/ci-news Above change helped and the localhost returns the CodeIgniter welcome page. But when accessing localhost/pages or any other linked when following --Build you first application are returning 404 file not found. Looking in to the Apache error log, it displays the following: [Sat Aug 01 09:19:43.734667 2020] [mpm_winnt:notice] [pid 6256:tid 264] AH00354: Child: Starting 150 worker threads. [Sat Aug 01 09:20:01.986693 2020] [authz_core:error] [pid 6256:tid 1524] [client ::1:1734] AH01630: client denied by server configuration: C:/xampp/htdocs/ci-news/app/ [Sat Aug 01 09:20:02.036693 2020] [authz_core:error] [pid 6256:tid 1524] [client ::1:1734] AH01630: client denied by server configuration: C:/xampp/htdocs/ci-news/system/ [Sat Aug 01 09:20:02.046693 2020] [authz_core:error] [pid 6256:tid 1524] [client ::1:1734] AH01630: client denied by server configuration: C:/xampp/htdocs/ci-news/writable/ [Sat Aug 01 09:21:32.715820 2020] [ssl:warn] [pid 7892:tid 252] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name [Sat Aug 01 09:21:32.745820 2020] [core:warn] [pid 7892:tid 252] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? [Sat Aug 01 09:21:32.745820 2020] [ssl:warn] [pid 7892:tid 252] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name [Sat Aug 01 09:21:32.775820 2020] [mpm_winnt:notice] [pid 7892:tid 252] AH00455: Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.8 configured -- resuming normal operations [Sat Aug 01 09:21:32.775820 2020] [mpm_winnt:notice] [pid 7892:tid 252] AH00456: Apache Lounge VC15 Server built: Apr 22 2020 11:11:00 [Sat Aug 01 09:21:32.775820 2020] [core:notice] [pid 7892:tid 252] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache' [Sat Aug 01 09:21:32.775820 2020] [mpm_winnt:notice] [pid 7892:tid 252] AH00418: Parent: Created child process 7916 [Sat Aug 01 09:21:33.056821 2020] [ssl:warn] [pid 7916:tid 264] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name [Sat Aug 01 09:21:33.086821 2020] [ssl:warn] [pid 7916:tid 264] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name [Sat Aug 01 09:21:33.116821 2020] [mpm_winnt:notice] [pid 7916:tid 264] AH00354: Child: Starting 150 worker threads. Looks like the permission issue or something else? Following the article below to see if that helps in resolving: http://httpd.apache.org/docs/2.4/upgrading.html#access RE: Build your first application - jreklund - 08-01-2020 This part aren't correct: Code: ServerName localhost/ Should be (for example) Code: ServerName codeigniter.localhost You can then access it with http://codeigniter.localhost Personally using this. Depending on what kind of settings you want. Code: <VirtualHost *:80> RE: Build your first application - pdos - 08-01-2020 Changed as follows: etc/hosts 127.0.0.1 codeigniter.localhost httpd-vhost.conf <VirtualHost *:80> ServerName codeigniter.localhost DocumentRoot "c:/xampp/htdocs/ci-news.localhost/public" <Directory "c:/xampp/htdocs/ci-news.localhost/public/"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost> Also now running the Xampp control panel with Admin access. Physical folder is at c:\xampp\htdocs\ci-news and undernath this folder codeigniter framework files. Now the codeigniter.localhost returning as object not found - 404. Thanks for keeping the patience. RE: Build your first application - jreklund - 08-01-2020 It needs to have correct physical path: DocumentRoot "c:/xampp/htdocs/ci-news/public" <Directory "c:/xampp/htdocs/ci-news/public/"> RE: Build your first application - pdos - 08-01-2020 Yes, corrected. Now the Welcome page is loading correctly, but the links to pages, pages/index etc is giving 404. Just like IIS failed request error logs, is there something in Apache that I can refer to as to which path it is going to when giving 404? RE: Build your first application - jreklund - 08-01-2020 Have you changed the applications url to match? Either in .env or app\Config\App.php https://codeigniter.com/user_guide/installation/running.html#id2 Set it into: Code: http://codeigniter.localhost/ Maybe you haven't activated rewrite? https://codeigniter.com/user_guide/installation/troubleshooting.html#i-have-to-include-index-php-in-my-url RE: Build your first application - pdos - 08-01-2020 Yes to both .env. App.php modified. Rewrite activated, yes. Still the same issue. Tried changing public $indexPage = 'index.php?'; instead of public $indexPage = 'index.php'; as per https://codeigniter.com/user_guide/installation/troubleshooting.html#i-have-to-include-index-php-in-my-url --Only the default page loads. That isn't helping. I will paste the structure with files info to give more insight in to the issue. Just in case if you can find it. RE: Build your first application - InsiteFX - 08-02-2020 Here is a template for creating VHOSTS using Windows and XAMPP. Code: #-------------------------------------------------------------- |