Wordpress子页面在恢复后抛出404

时间:2013-09-16 05:07:00

标签: wordpress apache .htaccess virtualhost web-hosting

虽然我有编程背景,但我是wordpress的新手。最近我将一个wordpress网站从justhost共享服务器移动到了 linode vps服务器(Ubuntu OS)。我做了以下步骤来实现它

  1. 在vps上设置apache2服务器
  2. 在vps上设置虚拟主机
  3. 在/ var / www / ftpadmin / www /下创建了一个目录 注意。创建ftpadmin是为了限制ftp访问该文件夹下的文件。这样做之后,我可以创建静态html和php网站。

  4. 从各自wordpress网站的justhost服务器上备份数据库和wp-content文件夹。

  5. 现在在vps上,在上面的指定位置,首先我下载最新版本的wordpress并解压缩文件。

  6. 在mysql上创建了同名的数据库,然后将原始数据库导入到同一个数据库中。

  7. 用原始文件夹替换了新的wp-content文件夹。

  8. 我正按照https://www.digitalocean.com/community/articles/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps的说明进行操作。

  9. 重启apache服务器。现在我可以访问主页。

  10. 我将wordpress网址和网站地址网址的数据库值更正为较旧位置的新网址,并重新加载数据库,这也帮助我访问了信息中心和登录页面。

  11. 我创建了一个.htaccess文件,如http://ahsan.vimmaniac.com/blog/enabling-wordpress-permalinks-on-ubuntu/.中所述

  12. 我还在/ etc / apache2 / sites-available /中的两个部分下更改了“AllowOveride”

    <Directory />
     Options FollowSymLinks
     AllowOverride all
    </Directory>
    
     <Directory /var/www/ftpadmin/www/domainname>
     RewriteEngine On
     Options Indexes FollowSymLinks MultiViews
     AllowOverride FileInfo
     Order allow,deny
     allow from all
     </Directory>
    
  13. 再次重启服务apache。

  14. 最后一点,我使用的是自定义模板,因此我有一个header.php和header-sub.php文件用于主页和导航。

  15. 现在问题就在于此。当我点击任何子菜单时,我收到“内部服务器错误”。

  16. 如果我删除.htaccess并重新加载apache服务器。现在,点击和子菜单时出现404错误。

  17. 任何帮助都非常感谢?我查看各个站点来整理这些步骤并执行。我不知道我该怎么做才能纠正这种情况。但是当我去仪表板时 - &gt;所有页面,我都可以找到存在于其中的所有页面。

    先谢谢 Fayaz

    修改 添加了评论中的.htaccess文件:

    <IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /wordpress/ (wordpress replaced with my domainname, bottom also) 
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /wordpress/index.php [L] 
    </IfModule>
    

2 个答案:

答案 0 :(得分:2)

我通过更换修复了上述问题        RewriteBase / wordpress / as“RewriteBase /”        和        RewriteRule ./wordpress/index.php [L}为“RewriteRule。/ index.php [L]”。 在.htaccess文件中。

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

答案 1 :(得分:1)

最后在浏览了几个小时并尝试了很多选项之后修复了这个错误。

在Apache httpd.conf文件的这个块中,(位于我的CentOS实例$ sudo vi /etc/httpd/conf/httpd.conf中)

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

将AllowOverride None更改为AllowOverride All。

Src:https://wordpress.org/support/topic/secondary-or-child-pages-returning-a-404-error-after-wp-34-update#post-3830892