I want to develop my codeigniter (v3) application at this address:
http://localhost/mycodeigniterApp/
I have :
$config['base_url'] = 'http://localhost/mycodeigniterApp/';
I get a 404 when I try to load any address in my applicaiton ( except for the default ).
Just closing this up the correct response was:
Couple checks make sure you class and file name of controller has
first letter upper case. Then check your routes.php
Related
i have added sitemap.xml file to my codeigniter project.
And i call it on my localhost like that : http://localhost/demo/sitemap.xml
it runs without any issue.
But when i run it on live server http://example.com/demo/sitemap.xml
it says 404 page not found.
What is issue ?
you need to add below things in your config/routes.php file
$route['sitemap\.xml'] = 'demo/sitemap'; // your navigation path i.e. your controller_name/function_name
When I'm sending a queued mail message from a laravel queue the route urls always return localhost instead of the url set in config app.url. The rest of the site works fine but just urls generated from the queue are wrong.
The url in app.php is only used when Laravel runs as a console application. Your URLs where created using the domain name the application runs under: localhost
You can fix this by only generating a relative URL and then prepend the domain name from the config:
$url = Config::get('app.url') . route('route-name', null, false);
(The third argument to route() is $absolute = true. By setting that to false you get a relative URL starting with /)
I am using the baseurl() in my application. ex: "http://www.edocapp.in"
This is working in case if we type domain name with "www" but not working if I use "only http".
Application is hosted on server.
try
$config['base_url'] = 'http://www.edocapp.in';
this
Base URL should have / in the last char:
$config['base_url'] = 'http://www.edocapp.in/';
anyway, you should check your DNS record in your server/hosting.
Does it have an alias (CNAME Records) to redirect www.edocapp.in to edocapp.in ?
In a Laravel 4 installation, Using Jeffrey Way's Laravel 4 Generators, I set up a 'tweet' resource, using the scaffolding command from his example:
php artisan generate:scaffold tweet --fields="author:string, body:text"
This generated the model, view, controller, migration and routing information for the tweet type. After migrating the database, visiting http://localhost:8000/tweets works fine, and shows the expected content.
The contents of the routes.php file at this point is:
Route::resource('tweets', 'TweetsController');
Now I would like to move the url for tweets up one level into admin/tweets, so the above url should become: http://localhost:8000/admin/tweets. Please note that I am not treating 'Admin' as a resource, but instead just want to add it for hypothetical organizational purposes.
Changing the routes.php file to:
Route::resource('admin/tweets', 'TweetsController');
Does not work, and displays the following error:
Unable to generate a URL for the named route "tweets.create" as such route does not exist.
Similarly when using the following:
Route::group(array('prefix' => 'admin'), function() {
Route::resource('tweets', 'TweetsController');
});
As was suggested in this stackoverflow question.
Using php artisan routes reveals that the named routes also now have admin prefixed to them, turning tweets.create into admin.tweets.create.
Why is the error saying that it cannot find tweets.create? shouldn't that automatically be resolved (judging by the routes table), to use admin.tweets.create?
How can I change my routing so that this error no longer occurs?
I just tested with new resource controller and it works fine for me.
The problem is not with the Route, its with the named routes used in your application.
check your view files there are link to route like link_to_route('tweets.create', 'Add new tweet'), this is creating the error because when you add admin as prefix tweets.create doesn't exists so change it to admin.tweets.create every where, in your controller also where ever named route is used.
I've got a working CodeIgniter website on my machine. However, when I move it to the live server, it says that it is unable to determine what should be displayed. I checked the paths, base URL and .htaccess and everything seems to be correct. How can I find out what the problem is?
Edit: This is the content of routes.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = "";
$route['404_override'] = '';
The error message does suggest that CI is attempting to fall back to the default controller which you have not specified. Assuming that the controller you are calling does exist this suggests that the problem might be to do with the server configuration and the way it is handling the URLs.
Try changing the URI Protocol in the config.php file (line 47). The default is 'AUTO' which works most of the time, but I have known servers that didn't like this. The comments in the file suggest various values you could try.
From the code supplied above, there is no default controller. CI requires a default controller is set, hence the error message.
If you have set one, then the problem isn't related to the above code.
You should setup your default controller in routes.php, for example
$route['default_controller'] = "home"; // home is the name of the controller