Remove index.php from Joomla! URLs with NGINX

前提是你 提交于 2019-12-11 01:15:59

问题


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

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

should become

http://domain.com/webpage

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

回答1:


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…

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

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



来源:https://stackoverflow.com/questions/28997028/remove-index-php-from-joomla-urls-with-nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!