1

こんにちは私はこれらをnginx形式に書き直そうとしていますが、進歩を遂げることができませんでした。これらをnginx用に書き直すのを手伝ってもらえますか?

# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !public/
RewriteCond %{DOCUMENT_ROOT}/public/$1.$2 !-f
RewriteRule (.+)\.(html|json|xml|atom|rss|rdf|txt)$ $1/ [L]

# Add a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.|\?)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]

# Rewrite any calls to /render to the image parser
RewriteCond %{REQUEST_URI} render/
RewriteRule ^render/. app/parsers/slir/ [L]

# Rewrite any calls to /* or /app to the index.php file
RewriteCond %{REQUEST_URI} /app/$
RewriteRule ^app/ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?/$1/ [L,QSA]

# Rewrite any file calls to the public directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/
RewriteRule ^(.+)$ public/$1 [L]

私はこれを試しましたが、うまくいきませんでした。

location  public/ {
}

location ~ (\.|\?) {
}

location ~ (.*)/$ {
}

location  public/ {
}

location / {
  if (!-e $request_filename){
    rewrite (.+)\.(html|json|xml|atom|rss|rdf|txt)$ /$1/ break;
  }
  if (!-e $request_filename){
    rewrite ([^/]+)$ /$1/ break;
  }
   if ($request_uri ~ "render/"){
    rewrite ^/render/. /app/parsers/slir/ break;
  }
  if ($request_uri ~ "/app/$"){
    rewrite ^/app/ /index.php break;
  }
   if (!-e $request_filename){
    rewrite ^/(.*)/$ /index.php?/$1/ break;
  }
  if (!-e $request_filename){
     rewrite ^(.+)$ /public/$1 break;
  }
}

これを試してURLを入力すると。ファイルをダウンロードします。

4

1 に答える 1

0

それがあなたの問題に完全に一致するかどうかはわかりませんが、これはあなたにいくつかの助けと次に探すための出発点を与えるはずです. そして、1つの提案-nginxはApacheとは少し異なるので、nginxのようなものを試さないでくださいif (!-e $request_filename)-それは本当に悪い考えです(ここについての何か:そのようにIFしないでください)

# It's your first rule:
# If request location match this regex then
# try file as request, if not exist
# try a folder matching * or
# return with 404
location ~ (.+)\.(html|json|xml|atom|rss|rdf|txt)$ {
   try_files $uri $1/ =404;
}

# It's firts part of your second rule:
# If request match this regex 
# try file as request if not exist
# try file with added slash or
# return with 404
location ~ !(\.|\?) {
   try_files $uri $uri/ =404
}

# It's second part of your second rule:
# If request match this regex
# try file as request if not exist
# try file with added slash or
# return with 404
location ~ !(.*)/$ {
   try_files $uri $uri/ =404
}

# It your third rule:
# Rewrite /render to /app/parsers/slir
location = /render {
   rewrite .* /app/parsers/slir break;
}

# It's first part of your forth rule:
# If request location match this request then use /index.php
# or return with 404
location ~ ^/app/$ {
   try_files /index.php =404;
}

# It's second part of your forth rule:
# If request location match regex try to use it,
# if not try /index.php?/$1/ location
# or return with 404
location ~ ^(.*)/$ {
   try_files $uri /index.php?/$1/ =404;
}

# It's your fifth rule:
# Try file with match this reqex, if not try location /public/$1
# or return with 404
location ~ ^/(.+)$ {
   try_files $uri /public/$1 =404;
}

# It's a global rule
# For all request try file as it is
# or return with 404
location / {
   try_files $uri =404;
}
于 2013-01-26T15:59:57.363 に答える