Apache 显示“/ 的索引”而不是 wordpress 站点。编辑 DocumentRoot 会破坏站点和 wordpress 登录

Apache 显示“/ 的索引”而不是 wordpress 站点。编辑 DocumentRoot 会破坏站点和 wordpress 登录

我可以单击“index of/”页面中名为“wordpress”的文件夹,它会带我进入我的网站。

我尝试使用:

nano /etc/apache2/sites-available/000-default.conf

和编辑

DocumentRoot /var/www/htmlDocumentRoot /var/www/html/wordpress

但这似乎破坏了我的网站。我不介意在 wordpress 上重新制作网站,因为它现在只是一个入门模板。但问题是,在我进行此更改后,我无法再使用域名末尾的“/wp-admin”登录 wordpress。相反,我得到了一个 404 错误页面。

有任何想法吗?

编辑:

以下是000-default.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

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

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4'''

答案1

我遇到了同样的问题,我偶然发现了这个帖子。它给了我一个提示。

该问题与 wordpress 配置有关。

首先,您必须保留 domain.com/wordpress 的配置

然后使用该 URL 进入 wordpress 仪表板。

前往设置

从 wordpress 地址和站点地址中的 url 中删除 wordpress 后缀

现在按照您说的更改 000-default.conf 的设置并更改 documentroot。

重启 Apache

瞧!

问题是,即使你更改了根文件夹,wordpress 仍配置为使用 domain.com/wordpress 并查找该路径中的所有文件

相关内容