10

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

Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
Forrestgump360
  • 101
  • 1
  • 1
  • 3

5 Answers5

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

hemnath mouli
  • 2,617
  • 2
  • 17
  • 35
12

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.

Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
  • For someone hosting on Debian (mine was 10 at time of writing) `httpd.conf` is named `apache2.conf` and is located in `/etc/apache2/` – ado387 Feb 14 '22 at 07:21
8

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
Peter VARGA
  • 4,780
  • 3
  • 39
  • 75
1

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>`
Community
  • 1
  • 1
Lasantha
  • 258
  • 1
  • 11
0

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.

L L
  • 1,440
  • 11
  • 17