WordPress subpages throwing 404 after restoring

I am a newbie to wordpress though I have programming background. Recently I moved a wordpress website from justhost shared server to a
linode vps server (Ubuntu OS). I did following steps to achieve it

  1. Set up apache2 server on vps
  2. Set up virtualhost on vps
  3. Created a directory under /var/www/ftpadmin/www/
    Note. ftpadmin was created to restrict ftp access to files under that folder. I could make work static html and php websites after doing so.

    Read More
  4. Took backup of database and wp-content folder from justhost server of respective wordpress website.

  5. Now on vps, at specified location above, first I download latest version of wordpress and unzipped the files.

  6. Created database of same name at mysql and then imported original to the same database.

  7. replaced new wp-content folder with the one from original one.

  8. I was following instructions on https://www.digitalocean.com/community/articles/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps.

  9. restarted apache server. Now I could access the home page.

  10. I corrected the database values for wordpress url and site address url to new one at older location and reloaded database which helped me access dashboard and login pages also.

  11. I created a .htaccess file like mentioned in http://ahsan.vimmaniac.com/blog/enabling-wordpress-permalinks-on-ubuntu/.

  12. I also changed “AllowOveride” under both section in /etc/apache2/sites-available/ as

    <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. restarted service apache once again.

  14. One final point, I am using a custom template and so I have a header.php and header-sub.php file for homepage and navigation.

  15. Now here is the problem. When I click on any submenu I get “Internal Server Error”.

  16. If I remove .htaccess and reload apache server. Now I get 404 error while clicking on and submenu.

Any help is highly appreciated? I looked at various sites to collate these many steps and execute. I have no Idea what I should do to correct this situation. But when I go dashboard -> All pages, I can find all pages existing there with contents.

Thanks in Advance
Fayaz

EDIT
Added .htaccess file from comment:

<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>

Related posts

Leave a Reply

2 comments

  1. I got the above problem fixed by just replacing
    RewriteBase /wordpress/ as “RewriteBase /”
    and
    RewriteRule ./wordpress/index.php [L} as “RewriteRule . /index.php [L]”.
    in .htaccess file.

    <IfModule mod_rewrite.c> 
     RewriteEngine On 
     RewriteBase / 
     RewriteRule ^index.php$ - [L] 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteRule . /index.php [L] 
    </IfModule>
    
  2. Finally fixed this errow after browsing for a couple of hours and trying many options.

    In this block in your Apache httpd.conf file, (located in my CentOS instance at $ 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
    

    change AllowOverride None to AllowOverride All.

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