I have a non-Wordpress site , www.example.com
For canonicalization purposes I have this in .htaccess :
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
This way all non-www links will be redirected to www version of site.
Recently I decided to attach a wordpress blog at www.example.com/blog . After the installation is complete, whenever I go to www.example.com/blog I get 404 – Page not found error. I tried both auto install with Fantastico and a manual install, with the same result.
I found out that when I remove the piece of code above from my .htaccess it fixes the problem, and wordpress installation is accessable and usable.
However, I would like to keep the the original htaccess settings, for SEO purposes. I tried to change url version in wordpress General Settings and then restore main site htaccess file – it would still break the wordpress and 404 is back again.
I tried to add next code in wp-config.php :
define('WP_HOME','http://www.example.com/blog');
define('WP_SITEURL','http://www.example.com/blog');
It didn’t fixed the problem either…
I understand it has something to do with htaccess. I also notices that there is no htaccess file in wordpress folder, probably due to the fact that I haven’t changed permalinks settings yet.
I would appreciate any help on this matter!
P.S: I just noticed that www.example.com/blog/wp-login.php is visible regardless of htaccess config, however after I log in it brings me to 404 page again 🙁
As per @Milo, I’m adding my comment above as an answer…
Try going to
example.com/blog/wp-admin/options-permalink.php
. That should work, because the php file actually exists. If so, try updating your permalink options to a friendly version, like “Day and name”. This will put a new.htaccess
in the blog directory — I’m thinking that that new.htaccess
will override the one in the parent directory.You don’t need that code. WordPress itself handles redirects to canonical URLs. Just set it up to have the www address in Settings->General and it will redirect the traffic without your htaccess rules.