Apache HTACCESS 2 NGINX规则,有什么可以帮我的吗?

Apache HTACCESS 2 NGINX规则,有什么可以帮我的吗?,apache,.htaccess,mod-rewrite,nginx,Apache,.htaccess,Mod Rewrite,Nginx,我有一个网站需要从apache2移动到nginx,一切都好,除了htaccess。我用谷歌搜索了一些在线工具&,但它们都不起作用,甚至有一条规则: 任何人都可以帮助我,谢谢 <IfModule mod_rewrite.c> RewriteEngine on #First rewrite any request to the wrong domain to use the correct one (here www.) RewriteCond %{HTTP_HOST} !^www\.

我有一个网站需要从apache2移动到nginx,一切都好,除了htaccess。我用谷歌搜索了一些在线工具&,但它们都不起作用,甚至有一条规则:

任何人都可以帮助我,谢谢

<IfModule mod_rewrite.c>
RewriteEngine on

#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_php5.c>
    php_flag magic_quotes_gpc         off
    php_flag magic_quotes_runtime     off
</IfModule>
<IfModule mod_php4.c>
    php_flag magic_quotes_gpc         off
    php_flag magic_quotes_runtime     off
</IfModule>

找到了一个有趣的网站来完成这项工作:将htaccess转换为nginx配置:

根据自动转换,转换为:

# nginx configuration
location ~ /index.php$ {
}
location / {
    if ($http_host !~ "^www\."){
        rewrite ^(.*)$ https://www.$http_host$request_uri redirect;
    }
    rewrite ^(.*)$ https://$http_host$request_uri redirect;
    if (!-e $request_filename){
        rewrite ^(.*)$ /index.php break;
    }
}

似乎php模块配置没有转换为通用工具的定制方式。请告诉我这是否正常。

哎哟,请不要这样做,检查一下。同样,这是一个try_files案例,而不是重写。