.htaccess 从htaccess切换时,nginx的配置应该是什么?

.htaccess 从htaccess切换时,nginx的配置应该是什么?,.htaccess,mod-rewrite,configuration,nginx,.htaccess,Mod Rewrite,Configuration,Nginx,这是我有生以来第一次使用nginx 我知道nginx不遵循htaccess 重写规则我们在htaccess中应用的方式应该在nginx conf文件中应用。我不知道怎么做 我打开了nginx conf文件。我使用转换器将我的htaccess转换为nginx配置文件。我附加了htaccess和等效的配置文件 我甚至不知道是否启用了重写模块?或者我会说我不知道确切的方法来找到它 htaccess代码 RewriteEngine on # if a directory or a file exists

这是我有生以来第一次使用nginx

我知道nginx不遵循htaccess

重写规则我们在htaccess中应用的方式应该在nginx conf文件中应用。我不知道怎么做

我打开了nginx conf文件。我使用转换器将我的htaccess转换为nginx配置文件。我附加了htaccess和等效的配置文件

我甚至不知道是否启用了重写模块?或者我会说我不知道确切的方法来找到它

htaccess代码

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
php_value session.cookie_domain .abc.in
Nginx conf

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        #rewrite on;
        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        server
        {
                listen       80;
                server_name  abc.in;

                # nginx configuration

                location /
                {
                        if (!-e $request_filename)
                        {
                                rewrite ^(.*)$ /index.php;
                        }
                }
        }
}

我错了。这是一个路径错误。我在不同的位置更改文件

我从来没有在互联网上找到明确的文档

当我在nginx服务器上做一些工作时,我发现nginx确实启用了
站点
目录,其中保存了一个名为
default
的文件,该文件保存了服务器级配置

我把
index.html
改为
index.php
,一切正常