大网数据广告活动
网站运营与故障问答

How to enable use of .htaccess in Apache on Ubuntu?

· 52CE 我爱测

I'm trying to enable use of htaccess file in Ubuntu 14.04 (Apache 2.4.7). I know that this question has many possible duplicates, but none of them helped me yet. .htaccess ErrorDocument 404 /404.html 000-default.conf <VirtualHost…

问题原文

原帖链接 · David Abgaryan · CC BY-SA 3.0

I'm trying to enable use of htaccess file in Ubuntu 14.04 (Apache 2.4.7). I know that this question has many possible duplicates, but none of them helped me yet.

.htaccess

ErrorDocument 404 /404.html

000-default.conf

<VirtualHost *:80>
AccessFileName .htaccess

ServerAdmin webmaster@localhost
DocumentRoot /var/www

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/>
  Options Indexes FollowSymLinks Includes
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
</VirtualHost>

What else is needed?

已采纳解答

原帖链接 · Anil Prz · CC BY-SA 3.0

First Step

Open file as

sudo vim /etc/apache2/apache2.conf

Second Step

remove comment sign (#) if you find it before this line ( line number 187 approx.)

AccessFileName .htaccess

Third Step

Then find the line where there is

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

replace "None" with "All"

AllowOverride All

And voila... .htaccess works!!

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2014-04-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。