Migrated WordPress Site – Homepage Works, All Other Pages/Links Fail

KB ID 0001126 

Problem

I’m in the process of migrating the site back to its original VPS now that the site re-write and redesign has been completed. I used a plugin (UpdraftPlus) to backup the site, and its database, and then restored it to the new server. After the restore I connected to the new server and there was the site in all its glory 🙂

However, every single link I clicked gave me a;

Not Found

The requested URL {Path} was not found on this server

Solution

I struggled with this for a long time, internet searches all said, this is common, it’s because WordPress needs to update its ‘permalinks’, and it needs to write some code to the .htaccess file to do this.

WordPress will add the lines it needs, if you go to Settings > Permalinks, enter your setting, and click save. If it can’t write to the .htaccess file, then it will tell you and show you the code that needs adding, if that happens you have a permissions problem and WordPress has not got the rights to update the .htaccess file.

After much trial and error I deduced permissions were ok, and so was the .htaccess file and the permalink settings.

My problem was the mod_rewite module was not enabled for my website, and even though I’d got WordPress set up correctly Apache web server wasn’t letting the rewrite happen.

On my web server (CentOS7) I needed to edit the http.conf file. (I’m using nano, substitute vi for nano, if you don’t have it installed).

[box]

nano /etc/httpd/conf/httpd.conf

[/box]

Locate the section, that is for the directory /var/www/html, and edit the AllowOveride so that it is changed from None to All.

(WARNING: there will be a few AllowOverrides, change the correct one).

Save and exit the config file, then restart Apache

[box]

/sbin/service httpd restart

[/box]

Related Articles, References, Credits, or External Links

NA

RSS Error – Your feed appears to be encoded as “UTF8”, but your server is reporting “US-ASCII”

KB ID 0000889 

Problem

I don’t validate and check the sites RSS feed as often as I should, but post server migration I got this error;

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
Your feed appears to be encoded as “UTF8”, but your sever is reporting “US-ASCII”

Solution

As you can see by the section I’ve indicated above, I can see where the UTF-8 is being set on the page. I just need my server (CentOS with Apache2) to allow it.

1. Edit (or create a file in the same directory as the RSS XML file) .htaccess and add the following lines to the end.

[box]

# Add the UTF-8 Character Set
AddCharset UTF-8 .xml

[/box]

2. The restart Apache.

[box]

service https restart

[/box]

Related Articles, References, Credits, or External Links

NA

Google Analytics – Redundant Hostnames

(Redirecting non www URL’s to www URL’s)

KB ID 0001016 

Problem

I noticed this a while back, apparently Google Analytics started flagging this for many users on October 14th 2014. But I’ve only just got round to sorting it out.

If you are seeing this error its because your site is ‘addressable’ in more than one way, in my case you could get to me via http://petenetlive and http://www.petenetlive.com. I could have registered both in ‘Google Webmaster Tools’, and set one as a preferred site, but I didn’t want to update my Analytics code (I’ve got custom stuff in there I don’t want to re-write). So my next option is to do a ‘301 redirect’.

Solution

1. I use Apache web server, and I have my own VPS, so I can pretty much do what I want, If you side is hosted you may need to ask them to ensure that the rewrite_module is loaded on your web server. If you have your own you will need to take a look at your httpd.conf file.

2. Make sure that (like below), there is a line that is not commented out, that reads;

[box]LoadModule rewrite_module modules/mod_rewrite,so[/box]

3. Now in the root of your website edit (or create) the .htaccess file. And pate the following onto the end of it, (change accordingly);

[box]RewriteEngine On
RewriteCond %{HTTP_HOST} ^petenetlive.com
RewriteRule (.*) http://www.petenetlive.com/$1 [R=301,L][/box]

4. Save and upload the file (If using Notepad, make sure it does not put a .txt extension on the end of the filename – it should have NO extension).

5. Now go to http://your-website.com, (It will probably still work because your browser will attempt to load the page from its cache, so press CTRL+F5 to force refresh). If should redirect to http://www/your-website.com

6. To make doubly sure you can go here and type in http://your-website.com it should say something like;

HTTP/1.1 301 Moved Permanently
Date => Thu, 04 Dec 2014 19:41:48 GMT
Server => Apache/2.2.15 (CentOS)
Location => http://www.petenetlive.com/
Vary => Accept-Encoding
Content-Type => text/html; charset=iso-8859-1

<

7. Back in Google Analytics, select ‘Check again’.

5. It should say this.

6. Then it will say this ‘for ages!’.

 

Related Articles, References, Credits, or External Links

NA

Apache is Ignoring the .htaccess file

KB ID 0000890

Problem

The .htaccess file is a file that lives in a directory on a web server. Its job is to provide ‘settings’ that would normally be set in the servers httpd.conf file. You can put a .htaccess file in any directory to control the settings for that directory, (providing .htaccess override has been allowed).

After having some problems the other day, I made a change to mine, then reliased the change was not applying.

Solution

1. Connect to the server via SSH, (or open a terminal session). Logon as, (or su to) root.

2. Change to the directory that the httpd.conf file is in, (usually the /etc/httpd/conf/httpd.conf directory).

[box] cd /etc/httpd/conf/httpd.conf [/box]

3. First let’s check that the config, has been set to recognise .htaccess as the AccessFileName.

[box] grep -i AccessFileName httpd.conf [/box]

4. Then the server needs to actually allow the overide (this was my problem). The following will show you all instances of AllowOverride, make sure you check them all.

[box] grep -i AllowOverride httpd.conf [/box]

5. To edit the file and change the approriate settings from None to All.

6. Then restart the the web server.

[box] service httpd restart [/box]

 

Related Articles, References, Credits, or External Links

NA