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

Denis F. Latypoff latypoff at yandex.ru
Sat Oct 27 17:52:09 UTC 2012


27.10.2012, 21:22, "pattern" <nginx-forum at nginx.us>:
> Всем привет!
>
> Есть домен www.mydomain.ru на котором установлена joomla. Нужно чтобы URL'ы
> www.mydomain.ru/index.php
> www.mydomain.ru
> mydomain.ru/index.php
> перенаправлялись на
> mydomain.ru
> Конфиг сейчас выглядит так:
>
+ server {
+     listen 80;
+     server_name www.mydomain.ru;
+     return 301 http://mydomain.ru$request_uri;
+}

> server {
>     listen 80;
-     server_name mydomain.ru www.mydomain.ru;
+     server_name 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 = /index.php {
+         return 301 /;
>     }
>
>     location / {
-         try_files $uri $uri/ /index.php?q=$uri&$args;
+         try_files $uri $uri/ /index.php?q=$request_uri;
>     }
>
>     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;
+         include fastcgi.conf;
>     }
> }
>
> Все работает, за исключением того, что не могу никак добиться, чтобы
> mydomain.ru/index.php перенаправлялся на mydomain.ru. Подскажите, что ещё
> нужно добавить или удалить, чтобы получился желаемый результат?
>

-- 
br, Denis F. Latypoff.



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