V
V
Vladimir Krasnoselskikh2016-04-12 10:07:02
Nginx
Vladimir Krasnoselskikh, 2016-04-12 10:07:02

How to redirect from .php to / to Bitrix on Nginx?

How to redirect from .php to / to Bitrix on Nginx?
The rules are already in use:

location / {
                   try_files       $uri $uri/ @bitrix;
           }

           location ~ \.php$ {
                   try_files       $uri @bitrix;
                   fastcgi_pass 127.0.0.1:9000;
                   fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                   include fastcgi_params;
    }

           location @bitrix {
                   fastcgi_pass 127.0.0.1:9000;
                   include fastcgi_params;
                   fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
           }

           location ^~ /bitrix/admin/ {
                   try_files       $uri @bitrixadm;
                   fastcgi_pass 127.0.0.1:9000;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                   include fastcgi_params;

           }
           location @bitrixadm{
                   fastcgi_pass 127.0.0.1:9000;
                   include fastcgi_params;
#                   fastcgi_param SCRIPT_FILENAME $document_root/bitrix/admin/404.php;
                   fastcgi_param SCRIPT_FILENAME $document_root/bitrix/admin/index.php;
           }

Something like this rule:
location @rewrites {
            if ($uri ~* ^/([a-z]+)$) {
            set $page_to_view "/$1.php";
            rewrite ^/([a-z]+)$ /$1.php last;
            }
           }

But how to combine it with bitrix?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-04-16
Madzhugin @Suntechnic

No way. Because your admin panel will fall off.
But if you really want to add addresses starting with /bitrix/ to the exceptions

E
Evgeny Nikolaev, 2019-06-07
@nikolaevevge

Bicycle:
at the top of the /bitrix/modules/main/include/prolog_before.php and /bitrix/header.php files, check $_SERVER["REQUEST_URI"] for the presence of .php, if necessary, redirect to the required address.
To prevent anything from falling off, add exceptions to addresses, in particular, starting with /bitrix/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question