/ / apache / nginx:.htaccess rewrite conversion mayhem - Apache、mod-rewrite、url-rewriting、nginx、rewrite

apache / nginx:.htaccess rewrite conversion mayhem - Apache、mod-rewrite、url-rewriting、nginx、rewrite

私は、ApacheからNginxサーバー上で使用される.htaccessルールを書き直そうとしています。

RewriteCond $1 !^(index.php|assets)
RewriteRule ^(.*)$ /index.php/$1 [L]

ここには私が持っているものがあります。いくつかのより良い方向性が高く評価されるだろう。私は、インデックスをヒットすることができますし、大丈夫をロードし、資産のフォルダを参照して罰金が、より深いリンクは動作しません(PHPプログラムはdbクエリを構築するURLからvarsを抽出しています)。私は私が "近いうちに知っている..すべての返信をありがとう。

location / {
index index.php;
}
location /$ {
rewrite ^/(.*)$ /index.php/$1 last;
}
location /index.php {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}

回答:

回答№1は0

これらのルールは、/initex.phpへのアセットではありませんが、これはあなたが望むことをすると思います。また、ルートディレクティブとインデックスディレクティブをサーバーに移動します。これは、すべての場所のデフォルトとして設定する必要があります。

# set server defaults directly in server context
root /usr/share/nginx/html;
index index.php;

# location / is a fallback for any request that doesn"t match
# a more specific location
location / {
rewrite ^ /index.php$uri last;
}

# Serve content under /assets from disk
location /assets {
}

# Extract path info and send /index.php for processing
location /index.php {
fastcgi_split_path_info ^(/index.php)(.*)
include fastcgi_params;
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_pass 127.0.0.1:9000;
}