Joomla与Nginx重写SEF网址

时间:2014-01-04 18:50:55

标签: joomla nginx rewrite

我正在使用带有NGINX和PHP5-FPM的Ubuntu 12.04。我刚刚将我的Joomla网站从Apache迁移到了NGINX。但我认为重写规则效果不佳。

所有SEF链接都重写到主页,但在网址栏链接似乎是正确的。

示例如果我单击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/*;
   }

4 个答案:

答案 0 :(得分:1)

是的 - 这个回复超过3年,但不幸的是,使用NGINX时最新版本的Joomla存在同样的问题...

我们在其中一个客户的网站上遇到了完全相同的问题。事实证明这个问题与PHP的declare @date date set @date = '2016/02/30' select case_id, event_date from #total WHERE datepart(quarter, event_DATE) = datepart(quarter, @date) AND datepart(YYYY,event_DATE) = '2016' order by 2 常量之一没有被NGINX服务器设置有关 - 而且这个常量(`$ _SERVER [' PHP_SELF'])是在Joomla的许多地方用来返回当前的URL。我们已详细描述了问题以及如何解决问题,here

答案 1 :(得分:0)

如果您正在使用子文件夹/虚拟主机,请尝试更改:

# Support Clean (aka Search Engine Friendly) URLs
location / {
        try_files $uri $uri/ /index.php?q=$request_uri;
}

# Support Clean (aka Search Engine Friendly) URLs
location /subfolder/ {
        try_files $uri $uri/ /subfolder/index.php?q=$request_uri;
}

答案 2 :(得分:0)

您好这是我的主机配置,与Joomla 3.6.5友好URL,Ubuntu 16.04,PHP7和nginx一起正常工作:

server {
        listen 80;
        server_name mydomain.com;
        root /var/www/html/mydomain;
        index index.php index.html index.htm default.html default.htm;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        }
}

答案 3 :(得分:0)

我的解决方案是确保php.ini的这一部分已启用:rename_axis。这解决了未设置df = df.rename_axis(None, axis='columns') Company Name Computers Employees Monitors 2013 Aviators 20.0 10.0 NaN 2014 Aviators 2.0 12.0 NaN 2013 Mouses 1.0 4.0 5.0 2014 Mouses 8.0 13.0 1.0 的问题。

我是无意中禁用了它。

  

cgi.fix_pathinfo为CGI提供 real PATH_INFO / PATH_TRANSLATED支持。 PHP的先前行为是将PATH_TRANSLATED设置为SCRIPT_FILENAME,并且不获取PATH_INFO是什么。有关PATH_INFO的更多信息,请参见cgi规范。将此设置为1将导致PHP CGI修复其路径以符合规范。设置为零会导致PHP像以前一样运行。默认值为1。您应该修复脚本以使用SCRIPT_FILENAME而不是PATH_TRANSLATED。 http://php.net/cgi.fix-pathinfo