如何为Nginx重写Apache指令

时间:2013-06-03 18:49:23

标签: apache configuration nginx

是否可以为Ngnix重写下一个Apache指令?

1.设置默认字符集编码

Apache:

AddDefaultCharset UTF-8

2。重定向到一个域的SEO

的Apache:

<IfModule mod_rewrite.c\>
    Options +Followsymlinks
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^domain\.com [OR]
    RewriteCond %{HTTP_HOST} ^domain2\.com  [OR]
    RewriteCond %{HTTP_HOST} ^www\.domain2\.com
    RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]    
</IfModule>

3。在客户端缓存文件而不过期




    Header set Cache-Control "public"
    Header set Expires "Fri, 4 Jan 2022 20:00:00 GMT" 
    FileETag None


4。文字压缩

的Apache:



AddOutputFilterByType DEFLATE text/css

1 个答案:

答案 0 :(得分:0)

1

charset utf8;

2

server {
    server_name domain.com; 
    server_name domain2.com; 
    server_name www.domain.com; # www.domain2.com in RewriteCond, you mean www.domain.com?

    return 301 $scheme://www.domain2.com/$request_uri;   
}  

3

expires max; 

4

gzip on