gpt4 book ai didi

apache - .htaccess 未在 Ubuntu 14.04 (Apache 2.4.7) 中加载

转载 作者:行者123 更新时间:2023-12-04 18:54:47 24 4
gpt4 key购买 nike

我正在尝试使用 .htaccess Ubuntu 14.04 (Apache 2.4.7) 中的文件。

这是我的.htaccess好像

# 1 YEAR
<FilesMatch "\.(ico|svg|woff|eot|ttf)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>

# 1 WEEK
<FilesMatch "\.(jpg|png|gif|css|js)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>

# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType font/x-woff .woff
AddType image/svg+xml .svg

# Compress compressible fonts
AddOutputFilterByType DEFLATE font/ttf font/otf image/svg+xml

我使用 a2enmod rewrite 启用了 mod_rewrite

然后我编辑了 /etc/apache2/apache2.conf如下
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

AccessFileName .htaccess

然而 .htaccess文件仍未加载。如果我在 .htaccess 中添加乱码文件一切仍然正常。 .htaccess位于 /var/www/ .

这是 apache2ctl -S 的输出
VirtualHost configuration:
*:80 is a NameVirtualHost
default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost edmhunters.com (/etc/apache2/sites-enabled/edmhunters.com.conf:1)
alias www.edmhunters.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

我在这里错过了什么?

这是 apachectl -t -D DUMP_MODULES 的输出
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
expires_module (shared)
filter_module (shared)
headers_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
rewrite_module (shared)
setenvif_module (shared)
status_module (shared)
wsgi_module (shared)

最佳答案

默认情况下,apache 现在已关闭 .htaccess。

/etc/apache2/apache2.conf你应该能够找到类似于

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

将其更改为
AllowOverride All

然后重新启动apache,它应该可以工作。

您也可以在 sites-enabled 中逐个站点地骑行。文件夹,如果你愿意

有不止一次的地方 AllowOverride None,搜索 AllowOverride

关于apache - .htaccess 未在 Ubuntu 14.04 (Apache 2.4.7) 中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25816136/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com