Wordpress永久链接问题 - 非常永久链接中的额外“index.php”

时间:2012-06-01 23:23:33

标签: wordpress nginx permalinks

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

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

我尝试了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;
}

1 个答案:

答案 0 :(得分:0)

替换行:

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

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

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

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

相关问题