如何在 Nginx 中使用 .htaccess 文件? [英] How can I use an .htaccess file in Nginx?
本文介绍了如何在 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,你'可能做错了.").
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
tonginx.conf
(maybe the htaccess to nginx converter helps you) - use authd-htpasswd (I didn't try it)
这篇关于如何在 Nginx 中使用 .htaccess 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文