/theme/theme_1/*に/assets/* - >を書き直そうとしています。 書き換えURLは、.php-filesを除くすべてのファイルで機能します。Nginx - 書き換え後にPHPファイルが見つかりません
例のファイル構造:
- /theme/theme_1/images/image.jpg
- /theme/theme_1/images/user.jpg
- /theme/theme_1/ajax/register.php
- /theme/theme_1/ajax/read.php
問題は、私はこのURLで404を取得し、PHP-ファイルです: wgetのhttp://example.com/assets/ajax/read.php。 ファイルが発見された(200)(200)他のすべてのファイルが正常に動作しフルパスにhttp://example.com/theme/theme_1/ajax/read.php
を使用して: wgetのhttp://example.com/assets/images/image.jpg
nginxの設定ファイル:
server {
listen 80 default_server;
root /var/www/html;
index index.php index.html
server_name mysite.com;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /assets {
rewrite ^/assets/(.*) /theme/theme_1/$1 break;
}
location/{
try_files $uri $uri/ /index.php?$args;
}
}
'break'ではなく' last'を試してください。 –
これでうまくいかない場合は、 'try_files $ uri $ uri /index.php?$ args;'を 'location/assets {'ブロックに追加してください。 –
返信ありがとうございます。シンボリックリンクで簡単に修正しました。最高の解決策ではなく、私はむしろnginx-fixを持っているだろう:) – papegoj