【问题标题】:Permalink "Day and Name" issues with Wordpress and Apache VirtualHosts 404 ErrorWordpress 和 Apache VirtualHosts 404 错误的“日期和名称”问题
【发布时间】:2016-06-04 08:51:27
【问题描述】:

我一辈子都想不通如何让 Wordpress 在我的 Apache 服务器上使用漂亮的永久链接。我在网上搜索并尝试了无数种组合。有问题的 URL 是 www.trixiebangbang.com。我有一个在 Ubuntu 上运行的传统 LAMP 堆栈,全部由 AWS 托管。

我希望 Wordpress 的“日期和名称”永久链接正常工作。我已经在 Wordpress 中选择了它并更新了我的 .htaccess 文件并赋予它 755 权限:

# .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

当我查看我的博客文章时,这仍然会导致 404 错误。例如,如果我去this example blog post 它不起作用。然后我将 /etc/apache2/sites-enabled/000-default.conf 配置文件更新为以下内容:

# 000-default.conf file
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory />
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

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

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我非常小心,并确保在测试前进行的每次更改后都执行“sudo service apache2 restart”。有人可以告诉我这里有什么问题吗?提前致谢。

【问题讨论】:

    标签: wordpress apache http-status-code-404 virtualhost permalinks


    【解决方案1】:

    经过更多搜索,我能够拼凑出一个适合我的解决方案。我将 000-default.conf 文件更新为以下内容并重新启动服务器。我希望这对其他人有帮助。

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            ServerName trixiebangbang.com
    
            DocumentRoot /var/www/html
    
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/html>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    Allow from all
            </Directory>
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
    

    【讨论】:

    • AllowOverride All 在正确的文件夹上实际上就足够了。您可能在httpd.conf 上的/var/www/html 中有一个更全局的指令,现在您在虚拟主机中覆盖它。这太过分了,您可以在全局配置中对其进行修补。
    猜你喜欢
    • 2019-05-16
    • 2012-06-16
    • 2010-11-30
    • 1970-01-01
    • 2019-05-01
    • 2015-05-28
    • 2013-05-29
    • 2016-02-05
    • 2018-04-23
    相关资源
    最近更新 更多