繁体   English   中英

更改要与Nginx一起使用的Apache .htaccess文件

[英]Change Apache .htaccess file to be used with Nginx

我正在将网站从具有Apache Web服务器的服务器迁移到另一台运行Nginx Web服务器的服务器,我想转换.htaccess文件,问题不仅仅在于语法,还在于文件名。它还是.htaccess还是什么?

这是我使用的工具:

http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

它不是100%准确,但相当不错的基础

另外,这是有关转换规则的链接:

http://nginx.org/en/docs/http/converting_rewrite_rules.html

这可以帮助一点:

http://wiki.nginx.org/HttpRewriteModule#rewrite

编辑:

文件名应为nginx.conf

Nginx 不支持.htaccess文件。

但是.htaccess文件不好。 这是一种将apache配置的各个部分放置在文件系统上的任何位置,并告诉apache在每次请求时检查文件系统,以查看是否没有适当的配置。 .htaccess文件的唯一实际用法是,如果您是主机提供商,并且希望允许用户进行某些Web服务器配置,则将一小部分配置委派给用户。

重新启动nginx时会编译nginx配置。 当然,如果您确实不关心信息泄露问题(例如用户掌握您的Web服务器配置),但是可以将几个文件放入Web目录中,但是它们与.htaccess相同,则每次请求时都进行读取完成,不是以nginx方式。

http://wiki.nginx.org/LikeApache-htaccess

你做不到 你不应该 如果需要.htaccess,则可能做错了。

看这里:

https://www.digitalocean.com/community/questions/configuring-multiple-domains-and-subdomains-dns-nginx-issues-abound

server {  
    server_name  domain1.com;  
    rewrite ^(.*) http://www.domain1.com$1 permanent;  
}  

server {  
    listen 80 default_server;  
    listen [::]:80 default_server ipv6only=on;  
    root /home/user/www/domain1;  
    index index.php index.html index.htm;  

    server_name www.domain1.com;  

    include hhvm.conf;      
} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM