Apache mod_rewrite到Nginx

时间:2017-02-24 04:13:17

标签: php .htaccess laravel mod-rewrite nginx

不确定如何将此更改为nginx mod_rewrite,尝试http://winginx.com/en/htaccess但未成功。

Apache重写是:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

有人帮忙吗?感谢

1 个答案:

答案 0 :(得分:0)

proxy_set_header HTTP_AUTHORIZATION $http_authorization;

if (!-d $request_filename){
    set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
    rewrite ^/(.*)/$ /$1 permanent;
}
if (!-d $request_filename){
    set $rule_1 1$rule_1;
}
if (!-f $request_filename){
    set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
    rewrite ^/ /index.php last;
}
if ($http_authorization ~ "."){
    set $rule_2 1$rule_2;
}