Routing not working correctly using the laravel framework
Posted
by
samayres1992
on Server Fault
See other posts from Server Fault
or by samayres1992
Published on 2013-06-26T10:14:59Z
Indexed on
2013/06/26
10:22 UTC
Read the original article
Hit count: 366
I'm using the book wrote by one of the guys that created laravel, so I'd like to think for the most part this code isn't horribly wrong.
My server is setup with nginx serving all static files and apache2 serving php.
My config for each are the following:
apache2:
<VirtualHost *>
# Host that will serve this project.
ServerName litl.it
# The location of our projects public directory.
DocumentRoot /var/www/litl.it/laravel/public
# Useful logs for debug.
CustomLog /var/log/apache.access.log common
ErrorLog /var/log/apache.error.log
# Rewrites for pretty URLs, better not to rely on .htaccess.
<Directory /var/www/litl.it/laravel/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
nginx:
server {
# Port that the web server will listen on.
listen 80;
# Host that will serve this project.
server_name litl.it *.litl.it;
# Useful logs for debug.
access_log /var/log/nginx.access.log;
error_log /var/log/nginx.error.log;
rewrite_log on;
# The location of our projects public directory.
root /var/www/litl.it/laravel/public;
# Point index to the Laravel front controller.
index index.php;
location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# PHP FPM configuration.
location ~* \.php$ {
proxy_pass http://127.0.0.1:8080;
include /etc/nginx/proxy_params;
try_files index index.php $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/php/$fastcgi_script_name;
}
# We don't need .ht files with nginx.
location ~ /\.ht {
deny all;
}
location @proxy {
proxy_pass http://127.0.0.1:8080;
include /etc/nginx/proxy_params;
}
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 405 /error/405.html;
error_page 500 501 502 503 504 /error/5xx.html;
location ^~ /error/ {
internal;
root /var/www/litl.it/lavarel/public/error;
}
}
I'm including these server configs, as I feel this maybe the issue?
Here is my incredibly basic routing file that should return "routing is working" on domain.com/test but instead it just returns the homepage.
<?php
Route::get('/', function()
{
return View::make('hello');
});
Route::get('/test', function()
{
return "routing is working";
});
Any ideas where I'm going wrong, I'm following this tutorial very closely and I'm confused why there is issue.
Thanks!
© Server Fault or respective owner