2013-08-06 1 views
1

magento에서 rule.php 규칙을 다시 작성하는 데 문제가 있습니다.Magento, url에서 index.php를 다시 작성하는 방법은 무엇입니까? (nginx)

Ex. 도메인/indoor.html은 500 내부 서버 오류이지만 도메인/index.php/indoor.html을 표시 할 수 있습니다.

My nginx.conf is 

    user root; 
    worker_processes 1; 

    error_log /var/log/nginx/error.log; 

    pid  /var/run/nginx.pid; 

    events { 
     worker_connections 1024; 
     multi_accept on; 
     use epoll; 
    } 

http { 
index index.html index.php; 
include  /etc/nginx/mime.types; 
default_type application/octet-stream; 

log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
        '$status $body_bytes_sent "$http_referer" ' 
        '"$http_user_agent" "$http_x_forwarded_for"';     

server_tokens  off; 
sendfile   on; 
tcp_nopush   on; 
tcp_nodelay   on; 


## Gzipping is an easy way to reduce page weight 
gzip    on; 
gzip_vary   on; 
gzip_proxied  any; 
gzip_types   text/css application/x-javascript; 
gzip_buffers  16 8k; 
gzip_comp_level  8; 
gzip_min_length  1024; 

## SSL global settings 
#ssl_session_cache shared:SSL:15m; 
#ssl_session_timeout 15m; 
#ssl_protocols    SSLv3 TLSv1 TLSv1.1 TLSv1.2; 
#ssl_ciphers    AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH; 
#ssl_prefer_server_ciphers on; 

keepalive_timeout 10; 

## Nginx will not add the port in the url when the request is redirected. 
#port_in_redirect off; 

## Multi domain configuration 
#map $http_host $storecode { 
    #www.domain1.com 1store_code; ## US main 
    #www.domain2.net 2store_code; ## EU store 
    #www.domain3.de 3store_code; ## German store 
    #www.domain4.com 4store_code; ## different products 
#} 

## Add www 
server { 
    listen 80; 
    server_name example.com; 
    return 301 $scheme://www.example.com$request_uri; 
} 

server { 
    listen 80; 
    #listen 443 ssl; 
    server_name 192.168.85.114; 
    root /var/www/html; 
    access_log /var/log/nginx/access_192.168.85.114.log main; 

    if ($http_user_agent = "") { return 444;} 

    #################################################################################### 
    ## SSL CONFIGURATION 

     #ssl_certificate  /etc/ssl/certs/www_server_com.chained.crt; 
     #ssl_certificate_key /etc/ssl/certs/server.key; 

    #################################################################################### 
    ## Server maintenance block. insert dev ip 1.2.3.4 static address www.whatismyip.com 

    #if ($remote_addr !~ "^(1.2.3.4|1.2.3.4)$") { 
     #return 503; 
     #} 

    #error_page 503 @maintenance; 
    #location @maintenance { 
     #rewrite ^(.*)$ /error_page/503.html break; 
     #internal; 
     #access_log off; 
     #log_not_found off; 
    #} 

    #################################################################################### 
    ## 403 error log/page 

    #error_page 403 /403.html; 
    #location = /403.html { 
     #root /var/www/html/error_page; 
     #internal; 
     #access_log /var/log/nginx/403.log error403; 
    #} 

    #################################################################################### 
    ## Main Magento location 

    location/{ 
     try_files $uri $uri/ @handler; 
    } 

    #################################################################################### 
    ## These locations would be hidden by .htaccess normally, protected 

    location ~ (/(app/|includes/|/pkginfo/|var/|errors/local.xml)|/\.svn/|/.ht.+) { 
     deny all; 
     #internal; 
    } 

    #################################################################################### 
    ## Protecting /admin/ and /downloader/ 1.2.3.4 = static ip (www.whatismyip.com) 

    #location /downloader/ { 
     #allow 1.2.3.4; allow 1.2.3.4; deny all; 
     #rewrite ^/downloader/(.*)$ /downloader/index.php$1; 
    #} 
    #location /admin { 
     #allow 1.2.3.4; allow 1.2.3.4; deny all; 
     #rewrite//@handler; 
    #} 

    #################################################################################### 
    ## Images, scripts and styles set far future Expires header 

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 
     open_file_cache max=10000 inactive=48h; 
     open_file_cache_valid 48h; 
     open_file_cache_min_uses 2; 
     open_file_cache_errors off; 
     expires max; 
     log_not_found off; 
     access_log off; 
    } 

    #################################################################################### 
    ## Main Magento location 

    location @handler { 
     rewrite//index.php?$args; 
    } 

    location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler 
     rewrite ^(.*.php)/ $1 last; 
    } 

    #################################################################################### 
    ## Execute PHP scripts 

    location ~ .php$ { 
     add_header X-UA-Compatible 'IE=Edge,chrome=1'; 
     try_files $uri $uri/ =404; 
     #try_files $uri $uri/ @handler; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     ## Store code with multi domain 
     #fastcgi_param MAGE_RUN_CODE $storecode; 
     ## Default Store code 
     fastcgi_param MAGE_RUN_CODE default; 
     fastcgi_param MAGE_RUN_TYPE store; ## or website; 
     include  fastcgi_params; ## See /etc/nginx/fastcgi_params; 

     if (!-e $request_filename) { 
      rewrite//index.php last; 
     } 
    } 
} 

}

하지만이 index.php를 다시 작성할 수 없습니다, 제발 종류의 해결이 나를 위해 제발 당신의 도움이됩니다.

답변

0

문제는 아마도 @handler 위치에 있으며, 직접 작성 했습니까, 아니면 magento 문서에 있었습니까?

내가 파일 /etc/apache2/apache2.conf 이 코드를 추가 할 rewrite^/index.php$request_uri;

+0

당신의 제안은 여전히이 문제를 해결할 수 없습니다. 이 문제는 @handler에 있습니까? –

-2

당신이 리눅스 시도에서 httpd.conf 파일

을 편집해야합니다 노력 좋을 것

<Directory "/var/www/magento"> // Path for your site 
    AllowOverride All 
</Directory> 
+1

죄송합니다, 나는 아파치가 아니라 nginx를 사용합니다. –

+1

이 질문은 Slowpache와 아무런 관련이 없습니다. –

3

최종 위치가되어야하는 곳에서 또 다른 try_files를 수행하여 루프를 만듭니다. 내가 데스크톱 뒤에있을 때 예를 들어 답을 수정 해 보겠습니다.

그래, Magento와 함께 작동하도록 nginx를 얻는 데 신경을 써야합니다. 먼저 당신이 문제가 당신의 거부 :

location ~ (/(app/|includes/|/pkginfo/|var/|errors/local.xml)|/\.svn/|/.ht.+) { 

해당 /의 pkginfo은/선도적 인 슬래시를 포함하지 않아야 안전한 IT/정보를 사용합니다. .svn 및 .ht의 이름을 지정하는 대신에 : Mercurial 또는 Git으로 전환 한 경우 액세스 권한도 필요하지 않습니다. 부수적으로 - nginx .ht는 필요하지 않습니다.

당신은/lib 디렉토리를 놓치고있어/그 두에서이 거부 나는 보통 분할 이유이다 : 첫 번째는 시작 부분에 고정되어

location ~ ^/(app/|includes/|pkginfo/|var/|errors/local.xml|lib/|media/downloadable/) { deny all; } 
location ~ /\. { deny all; } 

공지 사항. 이것은/lib /에 필요합니다. 왜냐하면/js/lib /가 열려 있어야하고 uri 요청의 시작에 고정되어 있지 않아야하는 유효한 경로이기 때문에 방문자가 JavaScript 라이브러리를로드 할 수 없기 때문입니다.

다시 쓰기 처리 :

먼저 기본 위치. 인덱스를 설정하고, uri를 시도하고 핸들러를 모두 catch로 정의하십시오. 핸들러에서

location/{ 
    index index.php; 
    try_files $uri $uri/ @handler; 
} 

는 index.php에 모든 것을 재 작성 :

location @handler { 
    rewrite/ /index.php; 
} 

마지막으로, 공정 PHP 파일을. try_files가 catch를하지 못하면 기존 PHP 파일에 대한 최종 검사를 수행 한 다음 경로 정보를 분할하고 params를 전달합니다. 멀티 스토어가 적용될 경우 변수 $ store를 기반으로 MAGE_ * 변수를 설정합니다. 이를 매핑하는 방법은 이미 설정에서 시작 했으므로 반복하지 않을 것입니다.

location ~ \.php(/.*)? { 
    if (!-e $request_filename) { 
     rewrite//index.php last; 
    } 
    expires off; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_split_path_info ^(.*\.php)(/.*)?$; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    fastcgi_param PATH_INFO $fastcgi_path_info; 
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
    fastcgi_param MAGE_RUN_CODE $store; 
    fastcgi_param MAGE_RUN_TYPE "store"; 
    include fastcgi_params; 
} 

그리고 그게 전부입니다. 희망이 도움이됩니다.

+0

고맙습니다. –

+0

@Melvin Hey, magento가 루트에 있지 않을 때 어떻게하는 것이 좋을까요? 현재 설치는 domain.com/mage에 거주하는 Magento 설치 및 domain.com/shop1/shop2에있는 여러 실제 상점입니다 (웹 사이트를 실행하도록 index.php가 수정되고 나머지는/mage에 심볼릭 링크 됨). – mniess

관련 문제