如何在Nginx中使用.htaccess文件

编程入门 行业动态 更新时间:2024-10-08 02:24:21
本文介绍了如何在Nginx中使用.htaccess文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前正在将我的网站从Apache迁移到nginx,但是我的.htaccess文件不起作用.我的网站在/usr/share/nginx/html/mywebsite文件夹中.如何在nginx服务器中使用.htaccess?

I am currently migrating my website from Apache to nginx, but my .htaccess file is not working. My website is inside the /usr/share/nginx/html/mywebsite folder. How can I use .htaccess in my nginx server?

这是我的.htaccess文件:

RewriteEngine on RewriteRule video/watch/([a-zA-Z0-9_@$*-]+)/?$ "videos-single.php?id=$1" [NC]

推荐答案

nginx不支持.htaccess(请参阅此处:"您无法执行此操作.您不应该执行此操作.如果您需要.htaccess,则可能是您做错了. ").

The nginx doesn't support .htaccess (see here: "You can’t do this. You shouldn’t. If you need .htaccess, you’re probably doing it wrong.").

您有两种选择(据我所知):

You've two choices (as I know):

  • 将您的.htaccess导入到nginx.conf(也许 htaccess到nginx转换器可以帮助您)
  • 使用 authd-htpasswd (我没有尝试过)
  • import your .htaccess to nginx.conf (maybe the htaccess to nginx converter helps you)
  • use authd-htpasswd (I didn't try it)

更多推荐

如何在Nginx中使用.htaccess文件

本文发布于:2023-11-02 06:15:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551595.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   如何在   Nginx   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!