Как удалить index.php из URL

pattern nginx-forum at nginx.us
Sat Oct 27 14:22:00 UTC 2012


Всем привет!

Есть домен www.mydomain.ru на котором установлена joomla. Нужно чтобы URL'ы
www.mydomain.ru/index.php
www.mydomain.ru
mydomain.ru/index.php
перенаправлялись на
mydomain.ru
Конфиг сейчас выглядит так:

server {
    listen 80;
    server_name mydomain.ru www.mydomain.ru;
    server_name_in_redirect off;
    charset utf-8;

    access_log /var/log/nginx/access.mydomain.log main;
    error_log /var/log/nginx/error.mydomain.log info;

    root /usr/home/mydomain/public_html;
    index index.php index.html index.htm default.html default.htm;

    if ($host = "www.mydomain.ru" ) {
        rewrite ^/(index\.php)?(.*)$ http://mydomain.ru/$2 permanent;
    }

    location /index.php {
        rewrite ^/(.*)$ http://mydomain.ru permanent;
    }

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

    location ~ \.php$ {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Все работает, за исключением того, что не могу никак добиться, чтобы
mydomain.ru/index.php перенаправлялся на mydomain.ru. Подскажите, что ещё
нужно добавить или удалить, чтобы получился желаемый результат?

Posted at Nginx Forum: http://forum.nginx.org/read.php?21,232265,232265#msg-232265



Подробная информация о списке рассылки nginx-ru