Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将.htaccess规则转换为nginx.conf_.htaccess_Mod Rewrite_Nginx - Fatal编程技术网

将.htaccess规则转换为nginx.conf

将.htaccess规则转换为nginx.conf,.htaccess,mod-rewrite,nginx,.htaccess,Mod Rewrite,Nginx,您好,我正在尝试隐藏以下.htaccess行,以便arrowchat可以在我的nginx服务器中工作。我的arrowchat文件夹的位置如下/usr/share/nginx/html/arrowchat/,其中/usr/share/nginx/html/是我网站的根文件夹。我的VPS只有一个网站,www.jukpac.com。下面是.htaccess代码 <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteE

您好,我正在尝试隐藏以下.htaccess行,以便arrowchat可以在我的nginx服务器中工作。我的arrowchat文件夹的位置如下
/usr/share/nginx/html/arrowchat/
,其中
/usr/share/nginx/html/
是我网站的根文件夹。我的VPS只有一个网站,www.jukpac.com。下面是.htaccess代码

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^chatroom ^/../public/chatroom/ [L]
    RewriteRule ^cron ^/../public/cron/ [L]
    RewriteRule ^debug ^/../public/debug/ [L]
    RewriteRule ^list ^/../public/list/ [L]
    RewriteRule ^mobile ^/../public/mobile/ [L]
    RewriteRule ^popout ^/../public/popout/ [L]
    RewriteRule ^video ^/../public/video/ [L]
</IfModule>

<IfModule mod_headers.c>
 <FilesMatch "\.(gif|jpg|png|css|swf)$">
  Header add "Expires" "Mon, 28 Jul 2014 23:30:00 GMT"
  Header add "Cache-Control" "max-age=31536000"
 </FilesMatch>
</IfModule>

<IfModule mod_expires.c>
 ExpiresActive On
 ExpiresDefault A604800
 ExpiresByType text/css A604800
 ExpiresByType image/gif A604800
 ExpiresByType image/png A604800
 ExpiresByType image/jpeg A604800
 ExpiresByType application/x-shockwave-flash A604800
</IfModule>

在朋友的帮助下,在Serverfault中,我成功地获得了如下所示的正确配置

    server { #redirecting server
    listen       80;
    server_name  jukpac.com;
    return       301 http://www.jukpac.com$request_uri;
}

server {
    listen       80;
    server_name  www.jukpac.com;
    root   /usr/share/nginx/html; #move the root to server level
    index  index.php # move index to server level
    error_page  404  /404.html;
    error_page   500 502 503 504  /50x.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~* \.(?:ico|css|js|gif|jpe?g|png|swf)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
    } 

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}

在朋友的帮助下,在Serverfault中,我成功地获得了如下所示的正确配置

    server { #redirecting server
    listen       80;
    server_name  jukpac.com;
    return       301 http://www.jukpac.com$request_uri;
}

server {
    listen       80;
    server_name  www.jukpac.com;
    root   /usr/share/nginx/html; #move the root to server level
    index  index.php # move index to server level
    error_page  404  /404.html;
    error_page   500 502 503 504  /50x.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~* \.(?:ico|css|js|gif|jpe?g|png|swf)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
    } 

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}

噢,我没有注意到这里的赏金啊,我没有注意到这里的赏金啊,实际上这仍然是旧的配置。@MohammadAbuShady抱歉做了一个错误的复制粘贴,编辑了它以反映正确的代码:)帮了我大忙!事实上,这仍然是旧的配置。@MohammadAbuShady抱歉做了一个错误的复制粘贴,编辑了它以反映正确的代码:)帮了我大忙!