Today, one of my clients mentioned that his rest api was not working and was returning 404 errors and the iphone app was broken due to the 404 errors.
As he is running wordpress the immediate thought was that wordpress was overriding something and showing 404 errors inside his api directory (usually 404 errors indicate that the folder/file does not exist but we checked and the folder was there).
Here is a visual example of the issue.
When i opened up his .htaccess file in his /api/ directory I could see the following which is pretty standard .htaccess format.
I noticed that the rewrite base was not being defined and this usually occurs when you have an apache server configured for “AllowOverride None” so I added another line to his .htaccess file to get it working again (see line 4 below RewriteBase /api/).
Lets say you have wordpress blog sitting in the following domain and directory:
But now, you want to move the blog to:
However, and here is the caveat, you want to maintain all your search engine pages for the blog because currently google is looking at and listing all the pages on domainA.com/blog and you need to tell google where to look for the moved pages.
Basically this is what you want to do:
OLD SITE: http://www.domainA.com/blog/cat-stories
NEW SITE: http://www.domainB.com/cat-stories
All you do is place the code below into a .htaccess file on http://www.domainA.com/blog/ and all your url’s will move to the new domain in a nice seo friendly manner using 301 redirects.
RewriteRule ^blog/(.*) http://www.domainB.com/$1 [R=301,L]
This code basically tells everyone that the pages have been moved from site A to Site B and it will keep all the url’s in place meaning you don’t have to make individual 301 redirects.