您的位置:首页 > 运维架构 > Apache

ubuntu14.04下直接修改apache2默认目录导致wordpress样式改变的解决办法

2017-01-06 22:58 846 查看
一开始看到网上有各种各样的解决方法:

第一种是直接将 sites-available目录下的000-default.conf中的下列代码:

DocumentRoot /var/www/html


修改为:

DocumentRoot /var/www/html/wordpress


这样修改后发现应用的样式有所改变

后来看到有人说需要把apache2.conf文件中的下列代码:

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


修改为:

<Directory /var/www/wordpress>
Options Indexes FollowSymLinks
AllowOverride All  //改成All是为了开启Rewrite模式
Require all granted
</Directory>


但是这样修改后导致的一个问题就是会出现页面无法访问,爆出了404 forbidden

其实有一个最简单的修改方式,就是修改apache的默认主页,而不是默认目录,这样apache收到请求后会在默认主页中找到你所指定的目录,然后跳转到相应的web应用的主页中去,修改方法如下:

由于不同apache版本不同,需要先用一条命令找到我们要修改的文件:

grep -iR DirectoryIndex /etc/apache2


这个时候应该找到一个dir.conf文件,打开它,应该有如下内容:

<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /wordpress
</IfModule>


我们只需要在后面加上我们的web应用目录即可

修改后为:

<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /wordpress
</IfModule>


注意:我们这里的wordpress的存放方式如下:wordpress的所有文件存放在一个/var/www/html/wordpress目录下;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐