2014-04-20 62 views
1

我正在將Kohana應用程序版本3.0.4從Apache遷移到NginX。 我遇到了配置.htaccess的麻煩。在Nginx的正常工作只有內部URL的一樣:將Kohana從Apache遷移到NginX

http://myurlwithoutwww.net.ds/internalpage/anotherpage 

但幽冥主頁

http://myurlwithoutwww.net.ds/ 

幽冥這樣的:

http://myurlwithoutwww.net.ds/index.php 

作品。最後兩個將只顯示一個空白屏幕。

這是從那裏我試圖遷移htaccess文件:

AddType text/x-component .htc 
#Accept-Encoding: filter,deflate 
# Turn on URL rewriting 
RewriteEngine On 
AddDefaultCharset UTF-8 

# Installation directory 
RewriteBase/

RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+).([a-z]{2,3})$  [NC] 
RewriteRule ^(.*)$  http://www.%{HTTP_HOST}/$1   [L,R=301] 

# Protect hidden files from being viewed 
<Files .*> 
    Order Deny,Allow 
    Deny From All 
</Files> 

# ExpiresActive On 
# <FilesMatch \.(bmp|png|gif|jpe?g|html?|ico|doc|swf)$> 
#  ExpiresDefault "access plus 10 days" 
# </FilesMatch> 

FileETag none 

# Protect application and system files from being viewed 
RewriteRule ^async/?(.*)?     index.php?dispatcher=async&$1 [NC,L,QSA] 
RewriteRule ^(?:_application|_modules|_system)\b index.php/$0 [L] 

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# Rewrite all other URLs to index.php/URL 
RewriteRule .* index.php?kohana_uri=$0 [PT,L,QSA] 
#RewriteRule .* index.php/$0 [PT] 

這我目前Nginx的配置:

server { 
    listen  80; 
    server_name localhost; 

    #charset koi8-r; 

    #access_log logs/host.access.log main; 
    include /etc/nginx/aliases.conf; 
    root /var/www/webroot/ROOT; 
    index index.php; 

    location/{ 
    expires off; 
     try_files $uri $uri/ @kohana; 
    } 

    # Prevent access to hidden files 
    location ~ /\. { 
    deny all; 
    } 

    location @kohana { 
    rewrite ^/(.+)$ /index.php$request_uri last; 
    } 

    location ~* \.php { 

      #location ~ /\. { deny all; access_log off; log_not_found off; } 
     include /etc/nginx/fastcgi_params; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_param SCRIPT_FILENAME /var/www/webroot/ROOT/$fastcgi_script_name; 
    fastcgi_param KOHANA_ENV development; 
     fastcgi_param PATH_INFO $fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT /var/www/webroot/ROOT; 
      fastcgi_index index.php; 
    } 

回答

0

嘗試下面的配置,還要檢查引導初始化,如果有'index_file'=> FALSE。

server { 
    listen  80; 
    server_name *.domain.com; 

    client_max_body_size 20M; 

    access_log /home/user/public_html/site/log/access.log; 
    error_log /home/user/public_html/site/log/error.log; 

    root  /home/user/public_html/site/public/; 
    index  index.php; 

    location/{ 
       # don’t check $uri/, send to php for nice error message 
       try_files $uri /index.php?$query_string; 
    } 

    location = /index.php { 
     include  fastcgi.conf; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
    } 
} 
0

這是很古老的問題,但也許你會發現它很有用,我的方式:

location/{ 
index index.html index.htm index.php; 
try_files $uri index.php; 
} 

location /kohana { 

rewrite ^(.+)$ /kohana/index.php?kohana_uri=$1 last; 
if (-f $request_filename) { 

        break; 
      } 
      if (!-e $request_filename) { 
        rewrite ^/kohana/(.+)$ /kohana/index.php?kohana_uri=$1 last; 
      } 
} 

我剛剛上市default.conf的主要部分。