我試圖從Apache環境中將工作的ExpressionEngine安裝遷移到另一個框上的NginX環境。我遇到了一個問題,試圖將一些.htaccess
重寫轉換爲NginX。轉換表達式引擎和Nginx服務器的重寫規則
該網站使用multi language module,因此需要針對每種附加語言的自定義重寫規則。
這是我的標準配置的虛擬主機,這似乎讓ExpressionEngine工作很好(無需多語言模塊):
server {
listen 80;
server_name domain.co.uk www.domain.co.uk;
root /var/www/vhosts/domain.co.uk/http;
# Redirects non-www to www
if ($host = 'domain.co.uk') {
rewrite ^/(.*) http://www.domain.co.uk/$1 permanent;
}
access_log /var/www/vhosts/domain.co.uk/log/access.log;
error_log /var/www/vhosts/domain.co.uk/log/error.log;
location/{
index index.html index.htm index.php;
# Removes index.php from URLs
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
# Standard pass for all PHP files
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/domain.co.uk/http$fastcgi_script_name;
}
# This is where all the ExpressionEngine magic happens
location ~ \.php($|/) {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/domain.co.uk/http$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
}
上面似乎很好地工作,做什麼,我想它。多語言模塊文檔基於Apache設置。對於每種語言它需要它自己的htaccess重寫規則目錄 - 有點像這樣:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.co\.uk$
RewriteRule (.*) http://www.domain.co.uk/ar/$1 [R=301,L]
# Remove index.php
RewriteCond $1 !^(index\.php) [NC]
RewriteRule ^(.*)$ /de/index.php/$1 [L]
我已經加入重建上面的規則:
location /de {
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /de/index.php/$1 last;
}
}
添加上述得到我沒有進一步的當我嘗試訪問http://www.domain.co.uk/de/my_page
時,這比404錯誤頁面要多。
所以,我想也許這是什麼做的fcgi_param SCRIPT FILENAME
,所以我改變了對:(加de
結束路徑)
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/spectrumhealthcare.co.uk/http/de$script;
現在這樣做,當我訪問http://www.domain.co.uk/de/my_page
給了我一個No input file specified
錯誤。
我現在在磚牆上,所以真的幫助SO社區可以幫助我。你還沒有讓我失望:)。