LINUX.ORG.RU

nginx редирект любого каталога на index.php

 , ,


0

1

есть рабочий конфиг

location ~ ^/ajax/not/ {
   fastcgi_index  index.php;
   try_files $uri $uri/ /ajax/not/index.php?$query_string;
   fastcgi_pass   unix:/var/run/php-fpm.sock;
   fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
   include        fastcgi_params;
}
можно как-то это правило модифицировать, если добавятся еще несколько каталогов в ajax, что бы в конфиге не добавлять похожие правила, например

location ~ ^/ajax/set/ {
   fastcgi_index  index.php;
   try_files $uri $uri/ /ajax/set/index.php?$query_string;
   fastcgi_pass   unix:/var/run/php-fpm.sock;
   fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
   include        fastcgi_params;
}

а сделать одно общее правило для таких случаев?


Ответ на: комментарий от sanekmihailow

добавил

location ~ ^/ajax/[A-z]+/ {
   fastcgi_index  index.php;
   try_files $uri $uri/ /ajax/[A-z]+/index.php?$query_string;
   fastcgi_pass   unix:/var/run/php-fpm.sock;
   fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
   include        fastcgi_params;
}

при запросе ajax/net/ 500 ошибка и в логе

rewrite or internal redirection cycle while internally redirecting to "/ajax/index.php"

Garcia
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.