【发布时间】:2015-12-08 08:21:14
【问题描述】:
在树莓派 2 上安装了 nginx 和 php 5.6。工作得非常好,但我的页面仍然从 xyz.com/index.php/whatever(错误)以及 xyz.com/whatever(完美)加载。我不希望 /index.php 加载我的主页。我希望它重定向到/没有index.php。这也适用于所有子文件夹。我究竟做错了什么??这是我建造的第一台服务器,因此我们将不胜感激。谢谢。
网站可用配置:
server {
root /data/something.com/www/something/public;
index index.php index.html index.htm;
server_name something.com.local;
# Logging
error_log /data/something.com/logs/error.log;
access_log /data/something.com/logs/access.log;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
# Disallow access to hidden files
location ~ /\. {
deny all;
}
# Some locations will never contain PHP files, handle it in the server
location ~ ^/(robots.txt|favicon.ico)(/|$) {
try_files $uri =404;
}
# Pretty urls no /index.php (THIS IS WORKING...BUT /index.php is still accessible?)
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
error_page 404 /index.php;
sendfile off;
# PHP
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# We don't need .ht files with nginx.
location ~ /\.ht {
deny all;
}
}
【问题讨论】:
标签: php redirect nginx laravel-5