• 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目录下;

  • 相关阅读:
    C#练习代码
    docker部署gitlab
    vim 缩进设置
    css 初步学习笔记
    tomcat
    201871010107公海瑜《面向对象程序设计(java)》第一周学习总结 公海瑜
    发现JavaScript真强大
    今天看了一點ant的內容,受益匪浅
    一道趣味問題
    一個挺適合初學者的Ant教程
  • 原文地址:https://www.cnblogs.com/zlgxzswjy/p/6258011.html
Copyright © 2020-2023  润新知