1

我将我的网站从 Apache 迁移到 Nginx,现在的问题是我的永久链接在 URL 中有一个额外的 index.php,我无法确定这是 wordpress 问题还是我的配置问题。

当我的帖子呈现原始链接时的示例:http://hs.com/2012/04/30/a-new-question/ 现在被链接为http://hs.com/ * index.php/ *2012 /04/30/一个新问题/

我尝试了 nginx 兼容性插件。还尝试了使用和不使用插件的自定义结构选项,但我无法理解发生了什么。Wordpress 说自定义的永久链接结构被保存,即使网站中的所有链接都被错误地呈现。

这是我对该站点的 nginx 配置。

server {
server_name harshasagar.com www.harshasagar.com;
access_log /srv/www/harshasagar.com/logs/access.log;
error_log /srv/www/harshasagar.com/logs/error.log;
root /srv/www/harshasagar.com/public_html;

if ($host ~* www\.(.*)) {
   set $host_without_www $1;
   rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo'
}

location / {
    index index.html index.htm index.php;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ \.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/www/harshasagar.com/public_html$fastcgi_script_name;
}
4

1 回答 1

0

换行:

try_files $uri $uri/ /index.php?q=$uri&$args;

try_files $uri $uri/ /index.php?$args;

并安装这个插件 - http://wordpress.org/extend/plugins/nginx-helper/

如果您在此之后遇到问题,请告诉我。

于 2012-09-29T17:27:13.827 回答