.htaccess 在本地主机上不起作用(manjaro)
Posted
技术标签:
【中文标题】.htaccess 在本地主机上不起作用(manjaro)【英文标题】:.htaccess not working on localhost (manjaro) 【发布时间】:2021-10-02 15:20:42 【问题描述】:我整个下午都在试图解决这个问题,但我自己解决不了。
我一直在尝试在 VSCode 中使用 .htaccess 来实现管理区域,但页面会在不询问我任何内容的情况下加载。
我没有收到任何错误,/var/log/httpd/error_log
也没有。
我在 httpd.conf 中这样修改了 AutoOverride:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride All
Require all denied
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/srv/http"
<Directory "/srv/http">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
未注释LoadModule rewrite_module modules/mod_rewrite.so
这是我的 .htaccess 文件:
RewriteEngine On
RewriteBase /
AuthName "Page d'administration protégée"
AuthType Basic
AuthUserFile "/home/badakzz/php/openclas-s-room/htdocs/sql/blog/admin/.htpasswd"
Require valid-user
老实说,我不知道在哪里搜索了,我对 Linux 很陌生,很少有人使用 Manjaro,所以他们似乎没有“/srv/http”作为 DocumentRoot(我试图复制我的 VSCode 项目进入,但它没有改变任何东西)。
提前感谢您在我的痛苦中帮助我...!
【问题讨论】:
【参考方案1】:我会推荐以下解决方案:
编辑:/etc/httpd/conf/extra/httpd-userdir.conf 文件 变化:
AllowOverride Option1 Option2 Option3
到:
AllowOverride All
保存并重启apache:
sudo systemctl 重启 httpd
测试一下。
【讨论】:
您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。 这当然需要更多信息,因为在这里启用 MultiViews 似乎没有意义?! 这没有提供问题的答案。一旦你有足够的reputation,你就可以comment on any post;相反,provide answers that don't require clarification from the asker。 - From Review以上是关于.htaccess 在本地主机上不起作用(manjaro)的主要内容,如果未能解决你的问题,请参考以下文章