Every thing works fine in localhost, but when I upload on server, login view is getting opened but, while in checklogin when I try to load model I am getting bellow error
Unable to locate the model you have specified: loginmodel
controller file: login.php
class Login extends CI_Controller {
public function checkLogin() {
$this->load->model('loginModel');
....
model file: loginModel.php
class LoginModel extends CI_Model {
config file
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['base_url'] = 'http://myattendance.co.nf/';
.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# FOR LIVE
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
# FOR LOCAL
#RewriteRule .* index.php/$0 [PT,L]
</IfModule>
Codeigniter 3+ requires First letter of your class file capital in linux machine. I think your live server is a linux machine and you are developing in windows machine. Just simply rename all of your class files (Controller, Model and Libraries) to first letter capital. eg: rename your model loginModel.php to LoginModel.php
Hope this would solve your problem.
php version may be different on server and local so please make class name and file name same. for example If Your class LoginModal then its file name should be LoginModal.php also same for controller class.
Change the model's file name, model file: loginModel.php to model file: Loginmodel.php,then change the name of the model's class name as well from class LoginModel extends CI_Model{} to class Loginmodel extends CI_Model{} then refresh your link, it will work.
Related
My old domain: domain.com
My laravel project in: domain.com/laravel/public
It's working well, but I don't want see public in URL.
I add new .htaccess file to my root laravel folder (domain.com/laravel/.htaccess) with:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
When I access to domain.com/laravel, my jQuery path is: domain.com/js/jquery.min.js
When I access to domain.com/laravel/public, my jQuery path is: domain.com/laravel/public/js/jquery.min.js
I don't want move all files in public folder to root folder, because really more files there.
Best regards,
I read more answers in more website, almost their said move all files in public folder to root folder of Laravel application.
It's not good if we have more files there, so, I was try with some way and finally, I just move index.php and .htaccess file to root application.
It's working well, I just change some code when using HTML::script, HTML::css and {{ asset }}
As normal, we using HTML::css('style.css'), I just add public before, like this: HTML::css('public/style.css')
I hope it helpful for someone.
Best regards.
This is my current solution:
<IfModule mod_rewrite.c>
RewriteCond $1 !^(public)
RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
You have to add a rewrite condition.
I am new in LARAVEL framework and I want to run a controller with just function of view a page
class TestController extends BaseController {
public function index()
{
return View::make('hai');
}
}
I set the routing in routes.php file as given below
Route::get('test','TestController#index');
I tried to run in mozilla with
localhost/laravel/public/test
but it shows
Not Found
The requested URL /laravel/public/test was not found on this server.
is there any problem in my .htaccess page ?
<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>
Any body please help me.
I'm assuming that you are on Ubuntu machine. To make it work, at first, enable the rewrite module by executing following command in the terminal
sudo a2enmod rewrite
Second, find "apache2.conf" file in your system, mine is located in
/etc/apache2/apache2.conf
In this file, find the following snippets of code:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Change "AllowOverride None" to "AllowOverride All". Save the file and restart the apache server by executing following command
sudo service apache2 restart
This should solve the issue. Cheers
Precondition: you will know that you have htaccess working, if when you first installed laravel and went to localhost/laravel/public/, you'd see the laravel logo.
The route is:
Route::get('/', function()
{
return View::make('hello');
});
Regarding Your route: you don't need to explicitly state the function (#index) in the route. Laravel has a default path it follows based on the HTTP request type. Check here (under the heading Actions Handled By Resource Controller) for more details on that.
Simply I refer you not modifying .htaccess file. From http://tisuchi.com/easy-way-handle-routing-laravel/:
Static Page Handling
Handling static page in laravel is one of the easiest way to handle
route. Open app/routes.php file and deleted everything from that.
Assume that, we are try to route into our following pages- home
(example.com), about (example.com/about), contact
(example.com/contact). To do so, just write following code in your
routes.php file-
/**
* Static page code
*/
Route::get('/', function(){
return View::make('home');
});
# For example.com/about
Route::get('about', function(){
return View::make('about');
});
/**
* Naming Route for static Page
*/
# For example.com/contact
Route::get('contatct', array('as' => 'contact', function(){
return View::make('contact');
}));
If you are really new in Laravel, highly recommend to look into following 2 tutorials-
http://freshwebdev.com/best-laravel-tutorial-beginners.html
http://tisuchi.com/easy-way-handle-routing-laravel/
Ofcourse, don't forget to take a look into official page of laravel.com.
Hope, it will work for you.
Have fun...
I have a website using MODx Revolution (2.2.10-pl, advanced install), let's call it www.example.com, which I want to be accessible with both http and https.
to achieve this, I tweaked the site_url context setting to be [[++url_scheme]]www.example.com/. Links created using [[~id]] seem to be alright, however, sometimes, the generated links are really weird. My interpretation is that the code to create links programmatically doesn't work with my settings, but I don't know why, or how else I would go about enabling both http and https.
Question first, examples below: How should I set the site_url or any other site/context setting so that links on my site work with both http and https? Optionally, is the behavior I see a bug, or expected behavior given Revolution's tag evaluation semantics?
Misbehavior examples:
When I click on "View" in the manager for a resource with the alias example, the address that is opened is
https://www.example.com/xyz/[[++url_scheme]]www.example.com/example/
where xyz is my manager URL. The expected URL is of course
https://www.example.com/example/
Another case where this happens is for failed logins; my login call looks like this (minus irrelevant parts):
[[!Login? &redirectToOnFailedAuth=`[[++unauthorized_page]]`]]
The unauthorized_page's expected full URL is
https://www.example.com/special/401
but the URL which is opened for a failed login as username is
https://www.example.com/[[++url_scheme]]www.example.com/[[++url_scheme]]www.example.com/special/401?u=username
The second example is the same for http, except for the scheme, of course; I haven't logged into the manager with http.
EDIT
.htaccess at the webroot:
RewriteEngine On
RewriteBase /
# redirect all requests to /en/favicon.ico to /favicon.ico
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en)/favicon.ico$ favicon.ico [L,QSA]
#RewriteRule ^(en|nl|de)/favicon.ico$ favicon.ico [L,QSA]
# redirect all requests to /en/assets* /assets*
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en)/assets(.*)$ assets$2 [L,QSA]
#RewriteRule ^(en|nl|de)/assets(.*)$ assets$2 [L,QSA]
# redirect all other requests to /en/*
# to index.php and set the cultureKey parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
#RewriteRule ^(en|nl|de)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
.htaccess in the manager's directory:
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/xyz/$1
The problem is with $modx->makeUrl(). For example, for the
[[!Login? &redirectToOnFailedAuth=`[[++unauthorized_page]]`]]
call, in core/components/login/controllers/web/Login.php:
public function checkForRedirectOnFailedAuth(modProcessorResponse $response) {
$redirectToOnFailedAuth = $this->getProperty('redirectToOnFailedAuth',false,'isset');
if ($redirectToOnFailedAuth && $redirectToOnFailedAuth != $this->modx->resource->get('id')) {
$p = array(
'u' => $this->dictionary->get('username'),
);
$message = $response->getMessage();
if (!empty($message)) $params['m'] = $message;
$url = $this->modx->makeUrl($redirectToOnFailedAuth,'',$p,'full');
$this->modx->sendRedirect($url);
}
}
the last two lines do a redirect to a URL generated with makeUrl, which will be something like [[++url_scheme]]www.example.com/etc (note: I'm not 100% sure here, as I can't easily look at the raw URL. The conclusions still hold, though). If the URL is simply shown on the page, this is no problem, because MODx will parse the tag before inserting it into the html output. However, as the URL is used directly for the redirect, no such replacement takes place, and the browser interprets it as a relative URL, resulting in target URLs such as https://www.example.com/[[++url_scheme]]www.example.com/etc.
So much for the problem. To avoid this, site_url must be a literal value without any tags in it. As a workaround, I now use the following snippet as the first thing in my template:
$modx->config['site_url'] = $modx->config['url_scheme'] . substr($modx->config['site_url'], strlen('[[++url_scheme]]'));
return '';
together with a [[++site_url]] of
[[++url_scheme]]www.example.com/
Note that some parts of MODx don't seem to notice this update, which is why it's important to still use [[++url_scheme]] in your site_url. As far as I can tell right now, the parts that don't see the update, stuff like [[~id]], work properly with url_scheme.
EDIT this does of course only fix the "View" buttons in the manager if you tweak the manager templates accordingly.
WARNING this is of course very hacky, and not yet tested very well. The fact that some features do not see the overwritten value means that you're introducing an inconsistency into your website, which may lead to subtle errors! If a more clean solution comes up, go for it!
I have a folder under my main controller-folder called admin, in that controller i have a file name admin.php which has a function xyz.
I want to access that function using this url
http://localhost/webroot/admin/xyz
However when I try to access it, it is giving me this error.
404 Page Not Found
The page you requested was not found.
this is code of my routes.php file
$default_controller = "welcome";
$controller_exceptions = array('welcome','forum');
$route['default_controller'] = $default_controller;
$route["^((?!\b".implode('\b|\b', $controller_exceptions)."\b).*)$"] = $default_controller.'/$1';
$route['404_override'] = '';
$route['admin'] = "admin/admin";
This is my .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Also mod-rewrite is enabled :)
Please let me know why is it not working and how can i make it work. Any kind of help is really appreciated. Thanks
Ensure that your routes are stored in application/config/routes.php (not router.php as specified in your question). Try adding a route that uses a wildcard, like this:
$route['admin'] = "admin/admin"; //Routes to 'index()' function
$route['admin/(:any)'] = "admin/admin/$1"; //Handles all other cases
:any will match a segment containing any character(s), after the admin segment, and will pass it/remmap it to the the admin controller.
The user guide contains more information on controllers in sub-folders and routing.
Why i can't get an image to work. I'm trying this:
background-image: url(jBootstrap/images/ui-icons_222222_256x240.png);
and it doesn't work. When i'm trying to access it trought URL i get an error:
Asset [stylesheets/jBootstrap/images/ui-icons_222222_256x240.png] was unable to be processed.
Can't get any images, tried in many variations of directories and still doesn't work. When i'm doing this on plain html-css it works perfectly, but not in laravel. What am I doing wrong ?
btw, i'm using Basset if it helps.
EDIT 1
Also including the additional information about a partial structure of my public folder and html link generated by basset:
public/
stylesheets/
jBootstrap/
images/
ui-icons_222222_256x240.png
main.css it contains the background-image...
when including the css file, in source code i see:
<link rel="stylesheet" type="text/css" href="http://localhost/Job/worker/myapp/public/7n3C5wypAmTi8VT8/application/stylesheets/main.css" />
Edit 2
Adding my public/.htaccess file:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Edit 3
Tried another way:
public/stylesheets/main.css
public/stylesheets/abc.jpg
in main.css I have code: body { background-image: url('abc.jpg') } and i'm getting nothing ...
Please help, struggling 2 days now ...
Found the problem... It was Basset package, it wat required to put $collection->apply('UriRewriteFilter'); into configurations.
I would naturally assume that one (or both) things are incorrect here:
Your .htaccess file is not checking for existing files when rewriting. Check to see if RewriteCond {%REQUEST_FILENAME} !-f exists in that file.
You are not requesting your background image from the root, i.e. absolutely. Try requesting the resource using a leading slash. For example, instead of calling foo.png, try calling /foo.png.
Try using setArguments('../') on your collection
'collections' => array(
'application' => function($collection) {
$collection->add('../vendor/twitter/bootstrap/less/bootstrap.less')->apply('Less');
$directory = $collection->directory('assets/stylesheets', function($collection) {
$collection->add('main.css');
})->apply('UriRewriteFilter')->setArguments('../')->apply('CssMin');
}
),
This did the trick for me.