操作系統(tǒng):ubuntu13.10
服務(wù)器:nginx 1.6
在nginx配置根據(jù)url指向不同訪問(wèn)不同的目錄
使用location /目錄名 { ... } 可以做到不同的目錄訪問(wèn)
但是我想搭建laravel4 framework,想通過(guò)/coolwifi/test就直接解析成/coolwifi/public/index.php/test,但是會(huì)報(bào)錯(cuò):
Symfony Component HttpKernel Exception NotFoundHttpException
但是通過(guò)http://localhost/coolwifi/public/index.php/test訪問(wèn)是可以的
我該怎么做?
default配置文件如下:
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? 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;
}
}
歡迎選擇我的課程,讓我們一起見(jiàn)證您的進(jìn)步~~
按照單個(gè)server怎么弄都不行,最后設(shè)置了多個(gè)server可以解決問(wèn)題,并且在本機(jī)的/etc/hosts配置了多個(gè)域名指向本地,使用不同的域名區(qū)分不同的目錄
請(qǐng)問(wèn)樓主使用過(guò)phalcon嗎?最近我學(xué)習(xí)了下phalcon,但是按你這樣設(shè)置所有的路由都重定向到了index/index了,請(qǐng)問(wèn)你有解決方案嗎?謝謝