ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Joomla与Nginx重写SEF网址

2019-07-08 23:09:50  阅读:168  来源: 互联网

标签:nginx rewrite joomla


我正在使用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.

标签:nginx,rewrite,joomla
来源: https://codeday.me/bug/20190708/1406685.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有