Forrestgump360
Forrestgump360

Reputation: 101

Wordpress issue: after migration only homepage works

A few days ago I tried transferring my wordpress website from shared hosting to vps but I've run into a problem.

After following many guides/tutorials and googling myself I can't figure out why it's not working. The homepage is the only page that loads all other pages 404. I've included some relevant files.

Does anyone have any ideas?

HTACCESS

httpd.conf

Partial directory listing - www.pastebin.com/BCPfRisB

Thanks in advance

Upvotes: 10

Views: 29430

Answers (5)

Peter VARGA
Peter VARGA

Reputation: 5186

I posted this answer because I didn't find an answer which offered all possible solutions. Consider this answer as a pleasant checklist which should help you to fix this issue.

a) Permalinks update. The following steps rebuild the internal settings.

a) Login to your WordPress dashboard.
b) Go to Settings -> Permalinks.
c) Don't make any changes, just click "Save Changes" button.


b) .htaccess needs the settings for the rewrite engine:

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

c) Also, due to an error in the Apache log file the following entry was needed as well in the your-wordpress.conf Apache file which is mostly in the /etc/apache2/vhostd.d directory.

<Directory your-wordpress-directory>
  Options Indexes FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

d) Assure mod_rewrite is enabled

a2enmod rewrite
Restart Apache

Upvotes: 8

Arpit Aggarwal
Arpit Aggarwal

Reputation: 29276

I too have the same issue, fixed it creating .htaccess in the root directory with following content:

/var/www/html/.htaccess

# 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

Along with editing httpd.conf placed in /etc/httpd/conf to set value of AllowOverride directive to All for the /var/www/html directory, as below:

<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

And finally restarting apache:

sudo service httpd restart

For all the steps related to deployment you can find here - Hosting WordPress Application on Centos Box.

Upvotes: 13

Lasantha
Lasantha

Reputation: 268

Related to this issues.

Wordpress 404 error on every page except homepage (After migration)

There is a wp plugin call 'duplicator', you can use it for small sites, else you should change the wp_options table siteurl and home url, then login to admin back end -> settings -> permalinks - set the permalinks and save,

Then you can set the .htaccess just set following code and test.

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

Upvotes: 1

hemnath mouli
hemnath mouli

Reputation: 2755

  1. Login to your wp-admin
  2. Go to Settings > Permalinks
  3. Don't make any changes, just click "Save Changes" button.

Your site's secondary page would work now.

Upvotes: 29

L L
L L

Reputation: 1470

You need to change your home and site url to the new url you moved to. The easiest way to do that would be to add this

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

to your wp-config.php
Just make sure to exchange the dummy links with your new website URL. Let me know if this helps.

Upvotes: 0

Related Questions