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';
Related
In localhost my site runs correctly, after i publish it in a test server it does not work and it prints this:
My login page runs without problems...
But after i click "login", i receive the error, but the URL is correct...
my config.php
$config['base_url'] = 'http://merge.***.it/merge/';
$config['index_page'] = 'index.php';
routes.php
$route['default_controller'] = 'auth/login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Try this.
Put blank in index_page.
$config['index_page'] = '';
& Use .htaccess in your root folder
RewriteEngine on
RewriteCond $1 !^(index\.php|phpinfo\.php|Charts|assets|uploads|application|sitemap\.xml|robots\.txt|gyan\.rss)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
I'm using CodeIgniter, and I'm new at it, as I'm in web development.
I'm having a problem with the base_url from CI: it leads to 404 Page not found.
Here is the referrence for the page:
<li>Cadastrar</li>
The controller's function:
function novo_usual(){
$this->load->view('html-header');
$this->load->view('html-footer');
$this->load->view('cadastro_usual');
}
My controller's name file starts in capital, like Usual.php, and it extends CI_Controller.
My altoloado.php:
$autoload['helper'] = array('url','html','form','funcoes');
My routes.php:
$route['default_controller'] = 'Home';
Finally the .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
See \application\config\config.php
$config['base_url'] = '';
write to this your site url.
for example
$config['base_url'] = 'http://test.com/';
and now if you use base_url('Usual/novo_usual') this is equal http://test.com/Usual/novo_usual
If you don't set site url then first of set its
//Site URL Path : application\config\config.php
$config['base_url'] = 'http://localhost/site_name';
Then add this :
<?php
echo site_url('Usual/novo_usual');
//OR
echo base_url('Usual/novo_usual'); ?>
At first you need to set your folder path in
\application\config\config.php
$config['base_url'] = '';
for example
$config['base_url'] = 'http://localhost/folder/';
I've managed to solve it.
Turns out that my project's name starts with 'G', and in my url I was calling it with 'g'.
Thanks guys.
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).
:-)
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.
When my website opens for the first time , it directly goes to this address: http://www.website.com/tr/main
But I want my link to be like this: http://www.website.com/
I can't remove "tr/main" links. How can I solve this problem?
Php Code:
$route['default_controller'] = "main";
$route['404_override'] = '';
$route['(tr|en)/(.+)$'] = '$2';
$route['(tr|en)$'] = $route['default_controller'];
Htaccess Code:
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/
RewriteBase /
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
In your config.php file write this code :-
$config['base_url']='http://Your Path/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['subclass_prefix'] = 'Base';
In your routes.php file write this code :-
$route['default_controller'] = "home";
$route['404_override'] = '';
Write the follwing code in your routes.php file :-
$route['default_controller'] = "main";
$route['404_override'] = '';
and then in your "main" controller i.e in main.php use
function index()
{
// write all your code inside this function
}