Laravel - Routing Issue - php

This is most likely completely noob and something simple ive missed but its been driving me mad all day and the IRC is not being very helpful :c
Using Laravel PHP Framework and routing is failing.
Environment:
Host machine Ubuntu 14.04
Guest Machine Laravel - Homestead Vanilla(Standard) Vagrant Box
Project:
Default unedited Composer Laravel Project
Behaviour
Navigate to /public you get the laravel project hello page(suggests friendly urls and routing is working fine). When you navigate to /account you get "No input file specified. "
The Code
-- app/routes.php --
Route::get('/', function()
{
return View::make('hello');
});
Route::get('/account', function()
{
return View::make('account');
});
PLEASE NOTE HERE THAT THE ACCOUNT.PHP WAS CREATED IN THE VIEWS FOLDER
Nginx Error Logs
2014/06/24 06:56:49 [error] 1307#0: *97 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/Code/profile_system/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.10.1, server: profile-system.app, request: "GET /accounts/create HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "profile-system.app"
So apparently the issue is that it cant find index.php in the / of the project. But laravel does not have an index.php in /.
Any ideas? See this link for complete environment info. happy to add anything else on request. https://gist.github.com/Jonjoe/6359e71e47b7a489109c

If you navigate to /public to see Laravel's welcome page then your server is not configured properly. You should be able to get the welcome page without the /public in URL.
Probably the simplest way is to use .htaccess file (placed directly in Laravel directory) with the content:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
It is not the best solution though. You should threat your public directory as the website root instead of the Laravel directory. You can read more here.

Posting the answer because if you don't know it will destroy you.
Laraval applications start after /public. Make sure your hosts file / Web server specifies the path to be /root/to/project/laravel-root/public. THEN ITLL WORK :p.
Im going to mark Linek's answer as correct becuase if it was a friendly url issue that is the correct fix.

Related

.htaccess working on XAMPP localhost but not on Webhosting

Hei guys,
for my webpage I wanted to implement some simple REST-Services to serve some Json.
To achieve that I created subfolder api and in this folder I created index.php and .htaccess file.
index.php uses AltoRouter to handle Routes called on /api.
.htaccess locks like following:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
mod_rewrite is enable on my webhoster. (I was abelt to test this using some simple examples served by the webhoster)
I tested everthing on my local computer using localhost xampp.
Everthing is working fine. (GET and POST Requests)
After uploading this to my webpage I figured out, that POST Requests are Redirected to GET and therefore are not working.
Can anybody help with that issue. I need this POST Requests to be redirected to my index.php and be handled there to make some data update on my webpage.
Regards
Manuel
There is an update:
My Webhoster seams to use a nginx proxy that redirects to Apache.
POST seams to get coverted to GET and therefore my mechanism is not working anymore.
Can anyone tell me how to force nginx to redirect POST as POST?
Manuel
You can include the PHP file in your /api folder in your PHP file in your Root folder.
Just add the line include "./api/index.php" to your PHP in the Root folder.
Then the functions work in the PHP file in the /api folder, without having to open that specific PHP file in the /api folder.
https://www.php.net/manual/en/function.include.php

Laravel not good work on localhost

I have a code (who works on remote server), but he don't want work on my VM linux (ubuntu 16).
Issues are varied :
CSS isn't read
#import and #expand don't work
Laravel routes don't work
Apache 2 rewrite_module is ok (classical solve for Laravel routes issue)
PHP 7 is ok (phpinfo is good), Laravel is ok (access to database via Eloquent is good).
I precise that my html code is generate via php artisan with blade.
I suppose that I forgot a step in my configuration but I don't see what...
Edit :
Change on Apache's config DocumentRoot from root of application to /public solve the CSS issue.
a valid .htaccess is now ok, without change.
So, now, my major issue is to find why
https://www.xxxxx.vvv/api/v3/docs works and https://localhost/api/v3/docs doesn't.
Given that https//www.xxxxx.vvv/ and http://localhost/ work in the same way.
versions : php 7.0.3
Laravel 5.0.4
(and I don't want update)
As you said, .htaccess file missed. So put it in public directory with the following code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

How can I upload my local Laravel web project to server?

I work on a website which i made from Laravel and now i need to push it to the server and go live. I'm new to Laravel hosting. Earlier I did coding by pure php and those days i just push the project to server and it works. My server is one.com and this is what i get when i copy my content and try to access the page.
please help me on this manner! thank you
Option 1: Use .htaccess
if it isn't already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)
Edit the .htaccess file so that it contains the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Laravel has an Entry Point (which is the index.php File). This File lives inside the public folder. To go L-I-V-E with a Laravel Project, you have to set your Document Root to point to the public Directory.
Right now, you can only access your Site by navigating to: http://van.lesthi.com/public/
At the moment of this writing; accessing the URL above throws somewhat of an SQL Error, which you may want to fix first....

Symfony2 remove web from the url on the external server

I've been looking for the solution for a long time. There are a lot of such topics and I know it. But I still can't figure it out. How can I remove web from the symfony2 project url? I tried to do this with htaccess looking like this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [L]
but it doesn't work. It gives me an error:
No route found for "GET /web/"
I really can't change the root directory on this server as only thing I have is FTP permission. Anybody has any idea for this?
Edit: I also tried a trick to put all the files from web in root directory and the rest of the project higher. The problem is the highest directory I have access to is the root.
You shall need to update your virtual host config file and set the DocumentRoot to point to the web folder.
For example you may currently have it set as
DocumentRoot /var/www/myproject/
but you need to update it to
DocumentRoot /var/www/myproject/web
More information can be found within the Symfony2 cookbook here
Also this shall stop anyone trying to access the config/parameters.yml

404 errors with Codeigniter on nginx when accessing controller

I'm using Codeigniter for my website, the root website works just fine which has a landing page, however I have a development section located /var/www/domain.com/www/dev/ which /var/www/domain.com/www/ is the root (landing page is stored there).
Now, when I go to domain.com/dev, my codeigniter website works fine, but when I load an controller, e.g. domain.com/index.php/search it gives me an 404 error.
In the error logs of domain.com it shows this:
2011/10/02 02:03:37 [error] 17042#0: *568 open() "/var/www/domain.com/www/dev/index.php/search" failed (20: Not a directory), client: xx.xx.xx.xx, server: domain.com, request: "GET /dev/$
Now I have no complete idea why it's doing this and how to resolve this issue. How can I stop this and also remove the "index.php" remove the URL because Codeigniter tutorials only contain apache's rewriterule which isn't valid on nginx.
I believe that codeigniter uses the front-controller pattern, which will redirect all requests to index.php using a rewrite rule.
As the rewrite rules are for apache and not nginx, the server is actually looking for a directory called search which lives under another directory called index.php and so on.
I don't have much experience when it comes to nginx, but I believe this blog post can help you come up with rewrite rules on nginx.

Categories