从Joomla删除index.php! NGINX的URL [英] Remove index.php from Joomla! URLs with NGINX

查看:176
本文介绍了从Joomla删除index.php! NGINX的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How do I remove index.php from my Joomla URLs? For example:

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

应该成为

http://domain.com/webpage

我一直在遵循发现的一些指南,但是所有这些都会导致重定向循环,404或内部服务器错误.我需要一些指导.

I've been following some guides that I've found but it all result in a redirect loop, 404 or internal server error. I need some guidance please.

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

Here is my current config (excluding failing attempts).

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

推荐答案

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

How do I remove index.php from my Joomla URLs? For example: http://example.com/index.php/webpage should become http://example.com/webpage. I've been following some guides that I've found, but it all result in a redirect loop…

nginx重定向循环中所述,删除索引网址中的.php ,您想要这样的东西来确保没有任何重定向循环:

As explained at nginx redirect loop, remove index.php from url, you'd want something like this to make sure there aren't any redirect loops:

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

以上假设,手动删除URL的index.php部分已在其余配置中得到正确处理.

The above assumes that manually omitting the index.php part of the URL is already handled correctly through the rest of your configuration.

这篇关于从Joomla删除index.php! NGINX的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆