gpt4 book ai didi

Joomla 与 Nginx 重写 SEF url

转载 作者:行者123 更新时间:2023-12-01 03:52:37 25 4
gpt4 key购买 nike

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

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

例如,如果我单击 example.com/a/b.html,它看起来像是转到 url 栏中的链接,但正在加载主页。

谢谢你的帮助。

/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;
}

}

配置文件
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 .

关于Joomla 与 Nginx 重写 SEF url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20925210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com