作者:刘小飘168585 | 来源:互联网 | 2023-10-12 14:43
操作系统:ubuntu13.10
服务器:nginx 1.6
在nginx配置根据url指向不同访问不同的目录
使用location /目录名 { ... } 可以做到不同的目录访问
但是我想搭建laravel4 framework,想通过/coolwifi/test就直接解析成/coolwifi/public/index.php/test,但是会报错:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
但是通过http://localhost/coolwifi/public/index.php/test访问是可以的
我该怎么做?
default配置文件如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| server {
listen 80 default_server;
listen [::]:80 default_server ipv6Only=on;
root /home/kimhwawoon/nginx;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location /coolwifi/ {
index index.php;
#if (!-e $request_filename) {
# rewrite ^/(.*)$ /public/index.php?$1 last;
# break;
#}
try_files $uri $uri/ /coolwifi/public/index.php?$args;
}
location /phpmyadmin/ {
index index.php
try_files $uri $uri/ /phpmyadmin/index.php?$args;
}
location /swagger/ {
index index.html index.php;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
} |