問題
https://example.com/myservice/login
で/path/to/myservice/public/login.php
にアクセスしたいが、できない。https://example.com/myservice/hoge
で/path/to/myservice/public/hoge.html
にはアクセスできる(phpファイル以外はすべてアクセス可能)
構成
Nginx + php-fpmにてサイトを作っています。PHPなので、アクセスされたくないところもあり、以下のようなファイル構成にしています。
/path/to/myservice - password - /public - index.php
そして、nginxに以下のような設定をしています(細かいところは省略してあります)
nginx
1location /myservice { 2 location ~ .php$ { 3 alias /path/to/myservice/public; 4 try_files $uri = 404; 5 6 disable_symlinks off; 7 fastcgi_pass 127.0.0.1:9000; 8 fastcgi_index index.php; 9 include fastcgi_params; 10 fastcgi_param SCRIPT_FILENAME /path/to/myservice/public$fastcgi_script_name; 11 } 12 location /myservice{ 13 alias /path/to/myservice/public; 14 index index.html index.php; 15 try_files $uri $uri/ $uri.html @extensionless-php; 16 } 17} 18location @extensionless-php { 19 rewrite ^(.*)$ $1.php last; 20}
@extensionless-phpとかは拡張子なしで.phpにアクセスするための部分なので、今回の問題とは関係ないはずです。
あなたの回答
tips
プレビュー