Get Error "Not Found The requested URL was not found on this server. Apache/2.4.38 (Debian) Server at localhost Port 80" When Dockerized Web - php

I dockerized my PHP (Codeigniter Framework) & MySQL app successfully and First page of my website works fine on http://172.18.0.4/welcome , but my problem is that when I want to go to another page of my website for example about page (http://172.18.0.4/welcome/contact). I face with this error:
Not Found The requested URL was not found on this server. Apache/2.4.38 (Debian) Server at localhost Port 80
*Note that all of my websites page work fine on real host using Xampp.
I was try to fix htaccess like this :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
and i set my routes.php like this,
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = false;
to this:
$route['default_controller'] = 'welcome';
$route['tentang'] = 'welcome/tentang';
$route['pelajaran'] = 'welcome/pelajaran';
$route['kontak'] = 'welcome/kontak';
$route['guru'] = 'welcome/guru';
$route['admin'] = 'welcome/admin';
$route['404_override'] = '';
$route['translate_uri_dashes'] = false;

change AllowOverride None to AllowOverride None in your apache http config.

Related

CodeIgniter - Controllers not working, only loading index page with plain text

I've been trying to find some other solutions online but none yet has worked as I need it to.
I'm working on a CodeIgniter project but, at some point I suppose I have edited something I should not. Now, when I try to call localhost/projectname/controller/function it does ALWAYS (no matter which controller, even if the welcome controller) it will load my index.php file, which is on the root folder of codeigniter (not Views), without any images or css whatsoever, just plain text.
My config.php:
$config['base_url'] = http://localhost:8080/projectname';
$config['index_page'] = '';
My routes:
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route[LOGIN_PAGE] = 'examples/login';
My .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
I've trying to install community-auth and now have been caught with the error, as previously I was just working on the index page design and only now have been trying to access other functions.
I'm using NetBeans 8.2 and XAMPP v3.2.4
This is the index page:
This is what I get while trying the access controllers/function this is the page loaded:
Any help? Any other information I should provide?
Remove the $route[LOGIN_PAGE] = 'examples/login'; from routes
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Once load the page and share the browser inpect console error

Getting error 404 when accessing my web application on another devices

Im trying to access my web application on others devices but when i click the login button it gives me a 404 error - the page doesnt exist.
On my computer works fine but in others i get that error.
I've check capital errors on the controllers names but it all seems to be fine.
Anyone have any idea on what it might be?
Config file:
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/CodeIgniter/mponto/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
htaccess file:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Routes:
$route['default_controller'] = 'Pages';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['login'] = 'Utilizador/login';
maybe you should change
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/CodeIgniter/mponto/'
to
$config['base_url'] = 'http://#yourdomain.xxx/CodeIgniter/mponto/'
and you should use route default controller for your login not pages
i dont know it will work or not , i am newbie
Try this code
$config['is_https'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false;
$config['base_url'] = 'http'.(($config['is_https']) ? 's' : '').'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['SCRIPT_NAME']).'/');
or
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/CodeIgniter/mponto/';
or
$config['base_url'] = 'http://Yourdomainname/CodeIgniter/mponto/';
You can just change base_url in config file.
$config['base_url']='http://base_url/path';

CodeIgniter Routing Not Working in Sub Directory

I have setup a CodeIgniter site but only the default routing seems to be working.
I have had to set it up as a sub dir of an overall site - so http://localhost/subdir is the default url - this seems to work with the basic out of the box routing.
I have added a Users controller with the following methods - login, logout, register so I was expecting http://localhost/subdir/users/login would work but I get :
The requested URL /subdir/users/login was not found on this server.
Apache/2.4.25 (Win32) OpenSSL/1.0.2k PHP/5.4.44 Server at apps.mediaforce.co.uk Port 80
My routes file is very basic so I tried adding a new route to it for the users controller but it made no difference.
$route['users/login'] = 'subdir/users/login';
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Where am I going wrong?
You don't need to include subdir in your route.
Hence update your $route['users/login'] to route to following:
$route['users/login'] = 'users/login';
Edit 1:
in your root create a .htaccess file if it doesnot exist and save the following content in it to remove index.php from your URL:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]

Only welcome controller loading in codeigniter when hosted under cpanel

The app which i'm creating using codeigniter is loading on my localhost. But when i uploaded the same into cpanel its showing "404 Page Not Found".
I'm able to access default welcome controller other than this it shows 404 page not found.
Below are my configuration in application/config/config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess configurations are as follows
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
configuration in application/config/routes.php are as below
$route['default_controller'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
If I change the default_controller to welcome then welcome is loading fine.
--Thanks in advance
As said in the comments : Your controller's file name must start with an uppercase.
See http://codeigniter.com/userguide3/changelog.html
Changed filenaming convention (class file names now must be Ucfirst
and everything else in lowercase).
:-)

CodeIgniter: 404 Page not found after push for server

I did some apps on my local machine, runs ok, but after send that to the server I am getting 404 error page, I tried all methods but none works, can you help me with that?
a2enmod rewrite is on.
I found in google I need use in the server the same version of my php I have in my localmachine or my app will not run, that is true?
my local:
application/config/config.php
$config['base_url'] = 'http://localhost:8888/app/';
$config['index_page'] = 'index.php';
my server:
application/config/config.php
$config['base_url'] = 'http://example.com/app';
$config['index_page'] = 'index.php';
I tried too:
application/config/config.php
$config['base_url'] = '';
$config['index_page'] = '';
I got stuck on that, can you help me with that?
Try this code in your .htaccess file, you are not providing access for your CodeIgniter Directory.
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /app/index.php/$1 [L]
Do This Configurations
In your config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
in config/routes.php file
$route['default_controller'] = '';//default controller name
$route['404_override'] = '';
then in .htaccess(this should be place out side of application folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
The error was: in controllers was like that: user.php so i renamed for User.php, i not understand well that, but fixed online my code.
using user.php run in my local but not in live, if somebody know why, please leave a comment too.
thanks all for the help.
cheers.

Categories