laravel 4 on shared hosting: PAGE NOT FOUND - laravel

Due to a client issue i have to put a laravel 4 application on shared hosting service.But i followed this process at [laravelio]which includes.
Place the files of the laravel public folder i.e. css, img, js etc; into public_html folder (don't dump public folder instead dump the files and folders in it).
Put all the remaining folders & files into another folder, say 'laravelcore' and place the laravelcore folder in the root (/home5/username/)
Open index.php in the public_html folder and replace the following lines as mentioned
require DIR.'/../bootstrap/autoload.php';
require __DIR__.'/../laravelcore/bootstrap/autoload.php';
$app = require_once DIR.'/../bootstrap/start.php';
$app = require_once __DIR__.'/../laravelcore/bootstrap/start.php';
Open paths.php file in laravelcore/bootstrap and replace the following line
'public' => DIR.'/../public',
'public' => __DIR__.'/../../public_html',
which is suppose to work but when i visit the url i get this : The requested URL /login was not found on this server.please what may be the problem as i dont get it.may be its about configuring the .htacces file.
Any help would be appriciated.Thanks
website is at :benin1897.com
i just discovered that there is no .htaccess file in th public_html folder.could that be the problem...
here is my file tree
(/home/benincom)
etc
logs
mail
oysg
app
bootstrap
vendor
publicftp
public_html
css
js
error_log
readme
pakage.json
robots.txt
tmp
NOW AM LOGGED ON BUT LARAVEL THROWS ME ERROR
/ / |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader | for our application. We just need to utilize it! We'll require it | into the script here so that we do not have to worry about the | loading of any our classes "manually". Feels great to relax. | / require DIR.'/../oysg/bootstrap/autoload.php'; / |-------------------------------------------------------------------------- | Turn On The Lights |-------------------------------------------------------------------------- | | We need to illuminate PHP development, so let's turn on the lights. | This bootstraps the framework and gets it ready for use, then it | will load up this application so that we can run it and send | the responses back to the browser and delight these users. | / $app = require_once DIR.'/../oysg/bootstrap/start.php'; / |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can simply call the run method, | which will execute the request and send the response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have whipped up for them. | */ $app->run();

Do you've got the route for login handeld in your /app/routes.php like this?
Route::get('/login', 'LoginController#login');
Or if you don't use Controllers ( Which isn't an good idea, but for quick / dirty testing... )
Route::get('/login', function(){
echo "Now we're going to login on this awesome website!!!";
});
More about the Laravel Routes
Edit 1
The Controller file ( /app/controllers/LoginController.php ):
<?php
class LoginController extends BaseController {
public function login() {
echo "Now we are going to login in this awesome website!!!";
// return View::make('pages/overig/login');
}
}
You stated that there isn't an .htaccess file in you public folder. There should be one.
Create the file and insert this content and try it again:
<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>

It sounds like the .htaccess file is not configured properly so you are not getting the 'pretty URLs'. Try copying the example file from here to your .htaccess http://laravel.com/docs/4.2/installation#pretty-urls.
In the meantime you should be able to access your application by prepending index.php. For instance /login wasn't working for you, but if you try /index.php/login it will work

Related

View page not found in Laravel

Today I went from my Windows server to Ubuntu. I transferred my Laravel project that I had on IIS to apache2 and installed mod rewrite. However, I can't see the pages. This is the error I get: View [pages.maintenance] not found.
This is what I added to the 000-default.config configuration file:
<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</ Directory>
This is my htaccess (found in /var/www/html/public, (my DirectoryRoot):
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </ IfModule>
    RewriteEngine On
    # Handle Authorization Header
    RewriteCond% {HTTP: Authorization}.
    RewriteRule. * - [E = HTTP_AUTHORIZATION:% {HTTP: Authorization}]
    # Redirect Trailing Slashes If Not A Folder ...
    RewriteCond% {REQUEST_FILENAME}! -D
    RewriteCond% {REQUEST_URI} (. +) / $
    RewriteRule ^% 1 [L, R = 301]
    # Handle Front Controller ...
    RewriteCond% {REQUEST_FILENAME}! -D
    RewriteCond% {REQUEST_FILENAME}! -F
    RewriteRule ^ index.php [L]
</ IfModule>
How come I get this? I checked the rewritten mod change and it's okay.

Wordpress localhost doesn't show front-end

Can't see the front end of my wordpress localhost.
The process I've done:
1. I installed wordpress locally with BitNami on Mac OX.
2. imported an existing data base to the phpmyadmin.
3. changed the wp-config file to support the local host database.
4. added these two lines
define('WP_HOME','http://localhost/wordpress');
define('WP_SITEURL','http://localhost/wordpress');
5. logged in to my wp-admin.
Now I can see the site's WP-ADMIN and do things in it BUT I cannot view the front end.
whenever I try i get:
can't establish a connection to the server at 127.0.0.1.
or if i try to view a post i get
"The requested URL /site/2013/02/13/idho_global/ was not found on this server."
If I'm trying to preview a draft I see it the way it should appear.
any help?
Check the database via phpmydmin and change the url if you didn't do it.
In the wp_options check if siteurl & home are set to localhost
Update : you should have a look to the 'Moving Wordpress page' https://codex.wordpress.org/Moving_WordPress
It explains very well ho to change permalinks and things to do after moving a Wordpress.
If your permalinks don't works, check if you have a .htaccess in the root directory. The content should be :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You need to update the database urls. Wordpress hardcodes them. Run the sql below replacing "old-url.com/wordpress" and "new-url.com/wordpress" with your urls
UPDATE wp_posts SET guid = REPLACE(guid, 'old-url.com/wordpress', 'new-url.com/wordpress');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'old-url.com/wordpress', 'new-url.com/wordpress');
UPDATE wp_options SET option_value = REPLACE(option_value, 'old-url.com/wordpress', 'new-url.com/wordpress');

Running a cron job with CodeIgniter

I need to run a cron job on a file using CodeIgniter but CodeIgniter won't let me run a file directly. i.e.
I can run the controller in the browser with:
api.example.com/index.php/cron
My hosting only lets me run PHP files and I can't do it via the command line because it won't let me run wget or curl.
How can I make CodeIgniter run a file like below:
api.example.com/index.php/application/controller/cron.php
I can call that file with my hosting.
Updated
Thought i would just update none of the options worked for me i ended up changing hosting and doing the following.
http://devsforrest.com/116/setup-a-cronjob-to-run-every-5-minute-on-media-temple
Not sure if this is what you're looking for, or if I'm answering you wrong, but the way I run my CRON jobs with CodeIgniter is simply doing this as the cron:
php /path/to/index.php controller function
Then in the controller I have this at the top of it
if( PHP_SAPI != 'cli') exit('My Custom Error Message');
Uset wget command along with your url to run cron in codeigniter file in your case it should be:
wget api.example.com/index.php/controller/function
and be careful do not use path of file use the url which invokes your function.
class Cron extends CI_Controller {
function index($dummy) {
// Crony command
}
}
Line: api.example.com/index.php/cron/index/dummy.php
Basicly given example uses the 3rd uri segment to pass a value ending on .php that you don't use.
Or else you can use good ol' Routing
Use .htaccess to append .php to the requested URL, i did not test the code below, but i hope it helps.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [R=301]
Use CURL and call your cronjob by URL. If CURL is enabled in your hosting that will be a good choice.
Create a PHP file name it cronjob.php in the root folder of your website and add the following script in a file.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/index.php/controller/method");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
?>
Now in the cronjob call the php file cronjob.php and it should work.
simply
/usr/local/bin/php /home/cpanel_username/public_html/sub_folder/index.php param1 param2 optional_param3 optional_param3
Here
cpanel_username - username of your domain cpanel,
sub_folder(optional) - if your web application is any folder
Param(parameters) - refers to controller and their methods(functions)
Codeigniter API Cronjob for godaddy hosting
CodeIgniter cron job API based daily 10 o clock
0 10 * * * /usr/local/bin/php public_html/folder_name/index.php controller_name funcation_name
For Me Working Fine

code igniter's localhost mamp model works but view does not

I have a strange problem:
I am using MAMP and Codeigniter and I see that view is not showing anything on the browser. Model works and the DB is wired up.
Here is the code that does not work on the local host:
$this->load->view('test/db_tester_view',$data);
Sadly there is no error messages!!? but here is the config:
$config['base_url'] = 'http://localhost:8888';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I spend 20 hours on this so your help is appreciated
Some tips:
Make sure error reporting is on, as usual (this should be in your bootstrap file, index.php):
error_reporting(E_ALL);
ini_set('display_errors', 1);
Make sure you did not disable these directives somewhere else in your script.
Windows and *NIX deal with uppercase/lowercase file names differently. Make sure your files are all normalized to lowercase to avoid problems with different operating systems.
The base url needs a trailing slash:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://localhost:8888/';
// OR...
$config['base_url'] = ''; // automagic
If you don't require the port to be set explicitly, you can remove it.

Symfony 1.4 routing issues only when using index.php and mod_rewrite

The most succinct way of summarizing the problem at hand:
Development is over, and everything was run against frontend_dev.php during development and testing
This means that all URLs were: server.com/frontend_dev.php/module/action/parm
Moving to production means switching environments, and thusly using index.php instead
server.com/index.php/module/action/parm
Part of moving to production is using mod_rewrite under Apache2 to make the “index.php” part of the URL vanish, but still be functioning
server.com/module/action/parm is still routed against index.php
The URLs are indeed appearing w/o the index.php part, but symfony routing is now complaining:
ie, server.com/goals which routes to goals/index
-- perfectly fine using frontend_dev.php or index.php as an explicit controller
server.com/index.php/goals
-- using no explicit controller (via rewrite):
[Tue Dec 14 12:59:51 2010] [error] [client 75.16.181.113] Empty module and/or action after parsing the URL "/goals/" (/)
I have verified the rewrite is indeed routing to index.php by changing the rewrite to something that doesn’t exist:
[Tue Dec 14 13:05:43 2010] [error] [client 75.16.181.113] script '/opt/www/projects/adam/web/index2.php' not found or unable to stat
I have tried rerouting to frontend_dev.php, but only am provided with more debug information from symfony, none of which is helpful:
404 | Not Found | sfError404Exception Empty module and/or action after parsing the URL "/goals/" (/).
stack trace
1. at () in SF_SYMFONY_LIB_DIR/controller/sfFrontWebController.class.php line 44 ...
2. at sfFrontWebController->dispatch() in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 170 ...
3. at sfContext->dispatch() in SF_ROOT_DIR/web/frontend_dev.php line 13 ...
I have tried the using the RewriteBase option in .htaccess, but that does not help any, nor changing the true/false in the configuration line of the controllers
I hope this provides enough to understand why we’re confused, and able to direct us to a resolution.
Following is the current .htaccess and index/frontend configuration lines
Index.php:
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
Frontend_dev.php:
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);
.htaccess:
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} ..+$
#RewriteCond %{REQUEST_URI} !.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
I had similar issue and setting 'AllowOverride' to ALL for Symfony's WEB folder in Virtual Host's config sorted out this problem.
Welcome to Stack Overflow.
Maybe you're confusing the "index" route with "index.php"?
These URLs should theoretically all work.
server.com/frontend_dev.php/goals/index
server.com/index.php/goals/index
server.com/goals/index
server.com/goals
I can't remember if the trailing slash, like server.com/goals/, works or not. There's a gotcha there.

Resources