[英]mod rewrite from apache to nginx
I'm having some trouble in transformation of htaccess from apache to nginx. 我在将htaccess从Apache转换为Nginx时遇到了一些麻烦。
actual htaccess rule: 实际的htaccess规则:
options +followsymlinks
RewriteEngine On
RewriteCond $1 !^(images|system|themes|css|js|flex|slider|rss|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteRule ^(.*) /index.php?$1 [L]
this rule set is used in expression engine 1.7 此规则集在表达式引擎1.7中使用
my current solution : 我目前的解决方案:
location / {
index index.php;
try_files $uri $uri/ @ee;
}
location @ee {
rewrite ^(.*) /index.php?/$1 last;
}
location /index.php {
include fastcgi_params;
set $script $uri;
set $path_info $uri;
if ($args ~* "^(/.+)$") {
set $path_info $1;
}
fastcgi_pass fastcgi-upstream_${server_name};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
}
location ~* \.php$ {
include fastcgi_params;
fastcgi_pass fastcgi-upstream_${server_name};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
but it not reflexting 100% the same thing as in htaccess. 但它不能与htaccess中的内容100%相同。
You can use the location block in Nginx. 您可以在Nginx中使用位置块。 This will redirect all your request to index.php.
这会将您的所有请求重定向到index.php。
location / {
rewrite ^/(.*) /index.php?$1 break;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.