[英]NginX : alias and location
您好StackOverflowers,
我在這個問題上奮斗了一天多。 我有2個站點,一個是應用程序,一個是前台wordpress。
文件如下:
- 應用程序:C:/Users/NICOLAS/Documents/www/index.php
- WordPress:C:/用戶/NICOLAS/Documents/www/wordpress/index.php
問題是我正在從apache遷移到nginx,並且無法更改URL。 映射必須是這樣的:
- 應用程序:必須獲得http://test.site/v1/index.php/products/view/shoes
- WWW / index.php文件/產品/視圖/鞋
- WordPress: http : //test.site/index.php必須獲得
- WWW / WordPress的/ index.php的
我無法配置NginX來做到這一點。 我不知道為什么,這種配置讓我頭暈! 我仍然不了解NginX的邏輯。 這是我的conf的重要部分:
root C:\Users\NICOLAS\Documents\www;
location ~ ^/v1/(.+\.php.*)$ {
alias "C:/Users/NICOLAS/Documents/www/$1";
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location ~ / {
alias C:/Users/NICOLAS/Documents/www/wordpress/;
location ~ \.php$ {fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
你能指出我的錯誤在哪里嗎?
謝謝 !
我認為以下做法會有效:
location /v1 {
alias "C:/Users/NICOLAS/Documents/www/";
location ~ \.php$ {
# php-specific part
}
location / {
alias C:/Users/NICOLAS/Documents/www/wordpress/;
location ~ \.php$ {
# php-specific part
}
}
您的第一個位置不起作用,因為alias
一個目錄。
也許您會檢查nginx
的日志文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.