从Joomla中删除index.php! NGINX的网址

时间:2015-03-11 20:47:18

标签: nginx joomla url-rewriting url-redirection ngx-http-rewrite-module

如何从Joomla网址中删除index.php?例如:

http://domain.com/index.php/webpage

应该成为

http://domain.com/webpage

我一直在按照我发现的一些指南进行操作,但这一切都会导致重定向循环,404或内部服务器错误。我需要一些指导。

这是我当前的配置(不包括失败尝试)。

server {
    listen [::]:80;
    server_name www.domain.com;
    return 301 http://domain.com$request_uri;
}

server {
    listen [::]:80;
    server_name domain.com;

    root /usr/share/nginx/www;
    index index.php index.html index.htm;

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

    location ~/favicon.ico {
        access_log off;
        log_not_found off;
    }

    location ~ \.php$ {
        try_files $uri /index.php;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }

    access_log /var/log/nginx/$host-access.log;
    error_log /var/log/wpms-error.log;
}

1 个答案:

答案 0 :(得分:1)

  

如何从Joomla网址中删除index.php?   例如:   http://example.com/index.php/webpage   应该成为   http://example.com/webpage。   我一直在关注我发现的一些指南,但这一切都会导致重定向循环......

正如nginx redirect loop, remove index.php from url所述,您需要这样的内容以确保没有任何重定向循环:

index index.php index.html index.htm;
if ($request_uri ~ "^/(.*)(?<=/)index\.php/?((?<=/).*)?$") {    return  301 /$1$2;  }

以上假设已经通过其余配置正确处理了省略URL的index.php部分。

相关问题