我正在使用Ubuntu 12.04与NGINX和PHP5-FPM.我刚刚将我的Joomla网站从Apache迁移到了NGINX.但我认为重写规则效果不佳.
所有SEF链接都重写到主页,但在url栏链接似乎是正确的.
例如,如果我单击example.com/a/b.html,它看起来像转到url栏中的链接但是正在加载homapage.
谢谢你的帮助.
/etc/nginx/sites-available/example.com文件
server {
listen 80;
server_name example.com;
#server_name_in_redirect off;
#access_log /var/log/nginx/localhost.access_log main;
#error_log /var/log/nginx/localhost.error_log info;
root /var/www/example.com/public_html/;
index index.php index.html index.htm default.html default.htm;
# Support Clean (aka Search Engine Friendly) URLs
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)${
return 403;
error_page 403 /403_error.html;
}
location ~ \.php${
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# caching of files
location ~* \.(ico|pdf|flv)${
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)${
expires 14d;
}
}
nginx.conf
user www-data;
worker_processes 8;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
# gzip_proxied any;
gzip_comp_level 6;
# gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
## Block spammers and other unwanted visitors ##
include /etc/nginx/blockips.conf;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
解决方法:
是的 – 这个回复超过3年,但不幸的是,使用NGINX时最新版本的Joomla存在同样的问题……
我们在其中一个客户的网站上遇到了完全相同的问题.事实证明这个问题与PHP的$_SERVER常量之一没有被NGINX服务器设置 – 并且该常量(`$_SERVER [‘PHP_SELF’])在Joomla的许多地方被用来返回当前的URL.我们已经详细描述了问题以及如何解决问题,here.