【问题标题】:Remove index.php from Joomla! URLs with NGINX从 Joomla 中删除 index.php!带有 NGINX 的 URL
【发布时间】:2015-05-13 20:34:11
【问题描述】:

如何从我的 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;
}

【问题讨论】:

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


    【解决方案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 部分已在您的其余配置中正确处理。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-22
      • 1970-01-01
      • 2014-03-08
      • 1970-01-01
      相关资源
      最近更新 更多