微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Joomla与Nginx重写SEF网址

我正在使用Ubuntu 12.04与NginxPHP5-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.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐