The project locally works fine $config['base_url'] = "localhost/";
Codeigniter is getting the default controller welcome and login.php, but login.php is not getting the resources from assets folder
all the get requests for a resource are not found. When I inspect I get errors
xGET example.com/assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css
net::ERR_ABORTED 404
CodeIgniter folder structure in Cpanel public_html
+application
+assets
+system
index.php
.htaccess
I've configured the application/config/config.php
$config['base_url'] = 'www.mysite.com/';
$config['index_page'] = '';
I've configured the application/config/autoload.php
$autoload['packages'] = array('url');
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
the pages are loading resources:-
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css">
Rather than using href="<?php echo base_url();?>assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css"> just use href="/assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css">
Also, add http:// or https:// to your base URL depending on your SSL status.
Try using link_tag from html helper.
First load html helper in controller, or make it autoload in config/autoload.php
$autoload['helper'] = array('html');
Then try putting this in your header block of view file:
<?php echo link_tag('assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css') ?>
Related
I have downloaded and using Codeigniter 3.1.11.
I have copied the same to as usual htdoc folder.
Tomcat is Binary Installed and service running and able to get
the Welcome page with http://localhost/CodeIgniter3111/index.php/welcome.
I have inserted in .htaccess as below.
RewriteEngine On
RewriteCond $1 !^(index\.php|assets|images|js|css uploads|fevicon.png)
RewriteCond %{HTTP_COOKIE} ais=([a-z0-9-_]+)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-f
RewriteBase /CodeIgniter3111/
RewriteRule ^(.*)$ ./index.php/$1 [L]
and also removed the index.php from Config.
$config['base_url'] = 'http://localhost/CodeIgniter3111'; and added the base url as well.
As I type in url (http://localhost/CodeIgniter3111/welcome), I am
getting below error in browser.
Not Found
The requested URL /CodeIgniter3111/welcome was not found on this server.
I appreciate support in advance.
$config['base_url'] = 'https://localhost:8888/Your folder name';
your port number should be there
I am having a problem after hosting my codeIgniter project on live shared hosting server.
Before doing that, I changed few things on my local server.
.htaccess file-
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
.config.php inside config folder-
$config['base_url'] = '';
$config['index_page'] = '';
to let it work properly on my local server without writing index.php in URL. But when I moved it to live server, I changed base_url as-
http://crm.sachinartani.com
as I am hosting it on my subdomain, but it always output-
404 Page Not Found
The page you requested was not found.
I watched all videos on YouTube and traversed all questions of StackOverflow but none of the solutions helped me. There is a folder aside application folder namely inc which contains CSS and JS files I am using in my project. I am able to access those files by URL as - http://crm.sachinartani.com/inc but I cannot access any controllers and views like this.
I was trying to add some styling in my localhost(wamp) lavarel project....
This is my style.css file located in public folder
p{font-weight:bold; size:20px; color:red;}
This is hello.blade.php file located in app/view folder
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="{{ URL::asset('style.css') }}">
</head>
<body>
<p>Test</p>
</body>
</html>
& My routes.php file is having following code:
Route::get('/',function(){
return View::make('hello');
});
.htaccess file located in root directory is
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
When I am trying to access that hello page by localhost, Test content is visible without any styling. Can anyone tell me what is going wrong with me??
Your directory structure is different from the default one shown here
You have to put the packages folder and these files into the public directory:
.htaccess
favicon.ico
index.php
robots.txt
Then to make your site work again change the document root of your apache server to path/to/application/public
There's a reason for the public directory. When you put it on a server on the internet you gain additional security because the user can only access what is in the public directory. (because the domain is pointing to this folder) If you use your current setup everybody could see your whole application. For example one could enter example.com/app/config/database.php and would see your database password.
Put it like this:
<link rel="stylesheet" href="{{ asset('style.css') }}">
Without URL::
I'm relatively new to CI and I'm wondering if anyone knows how to set the default page of CI. I just transferred my files from my local server to my remote server and am having some problems. Firstly, I think it's important to note that I edited the .htaccess file so that the index.php was removed from the URL.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Secondly, in my config.php file, I have:
$config['base_url'] = '';
$config['index_page'] = 'sportstream';
sportstream is the name of a controller that is found in the application/controllers/ folder. From my experiences without using CI (or any other framework), the index.php file inside of the public_html folder on the remote server is the one that is loaded by default upon visiting a site. But, with CI, whenever I try to visit my domain name, a 404 error is returned. I have tried setting to base_url to http://www.mysite.com without any luck.
Does anyone here know how to make it so that upon visiting http://www.mysite.com that http://www.mysite.com/sportstream will be loaded?
You need to add a RewriteBase in your .htaccess file:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
NOTE: I have added a ? after the index.php as well.
I would also set the follow to an empty string (after you have tried the above):
$config['base_url'] = '';
$config['index_page'] = '';
Finally, in your routes.php file:
$route['default_controller'] = 'sportstream';
Update
In application/config/database.php you need to change your database driver. On your localhost, MySQLi was the database driver set. On your remote server, however, MySQLi was not installed, so changing it to MySQL should fix the issue.
//old - works on local server
$db['default']['dbdriver'] = 'mysqli';
//new - works on remote server
$db['default']['dbdriver'] = 'mysql';
For some reason, Codeigniter just "breaks" and shows the blank screen with no errors.
You have to set default controller in $route['default_controller'] ="sportstream"; it is located in aplication/config/route.php, So when visitinghttp://www.mysite.com/thesportstream` controller will be loaded by default.
Check about default controller in User guide
Switch back the $config['index_page'] = '';
If you renamed the index.php then you must enter the index_page name in config or else you can keep it blank.
Recommended Codeigniter starter guide: http://net.tutsplus.com/tutorials/php/codeigniter-basics/
I build codeigniter project and i have tested it in my local machine using http://works.dev/rcsoft as base url. I upload that project to cpanel and my new url like http://testsomeone.org/rcsoft. Home page is working.
But it is not working for other controller page such as http://testsomeone.org/rcsoft/person. It is giving
Not Found
The requested URL /index.php/person was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
But it working for http://testsomeone.org/rcsoft/index.php/person
my .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
My config.php
$config['base_url'] = 'http://testsomeone.org/rcsoft/';
$config['index_page'] = '';
Please help me. What is the issue?
First open up application/config/config.php file and edit line #17 as the example below:
$config['base_url'] = 'http://testsomeone.org/rcsoft/';
Second, insert the following line right after RewriteEngine On in .htaccess file:
RewriteBase /rcsoft/
Is it working fine in your local machine?..if so then just change the details in routing file..then try ..