zoukankan      html  css  js  c++  java
  • ubuntu14.04下直接修改apache2默认目录导致wordpress样式改变的解决办法

    一开始看到网上有各种各样的解决方法:

    第一种是直接将 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目录下;

  • 相关阅读:
    MyBatis 框架系列之基础初识
    从零开始实现在线直播
    面试中关于Redis的问题看这篇就够了
    Spring Boot 中使用 MyBatis 整合 Druid 多数据源
    MyBatis的foreach语句详解
    小结:“服务器端跳转”和“客户端跳转”的区别
    Centos7.3安装vsftp服务
    Spring 注解@Value详解
    Spring中@Bean与@Configuration
    数据结构之LinkList
  • 原文地址:https://www.cnblogs.com/zlgxzswjy/p/6258011.html
Copyright © 2011-2022 走看看