[英]NGINX compile and gzip config (with rails 3 + php-fpm): “can't unzip” by torrent client from php tracker
[英]Can't redirect .php in nginx config
由於某些原因,Nginx拒絕從地址欄中刪除.php擴展名,也無法識別不帶擴展名的文件應視為.php文件。
我將一個.conf文件添加到/etc/nginx/conf.d中,如下所示:
server {
listen 80;
server_name www.example.com; # I put my domain name here
root /var/www/html;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
# http://www.tweaktalk.net/60/nginx-remove-php-file-extension-from-url
try_files $uri $uri/ @extensionless-php;
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
}
它什么也沒做。 是的,我知道我將其保留為example.com。 我已經改變了。
當我運行nginx -t -c /etc/nginx/nginx.conf
(包括它)時,它說很好。
我想念什么?
我最終只是修改了可用站點中的“默認”配置,創建了一個符號鏈接,然后將現有代碼粘貼到其中。 似乎可以工作!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.