1

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 :(

8
  • home and site url should be http://www.example.com/blog if it's installed in a folder named blog.
    – Milo
    Aug 7, 2011 at 16:14
  • yeah it is blog, sorry I submited the code from the example webpage, let me update original post
    – Alex
    Aug 7, 2011 at 16:16
  • 1
    what is the url it sends you to when you log in? make sure you clear your cache after any change, your browser will cache a 404 page. I tried your .htaccess rules on my own server and wp in a directory and it all works fine, not sure what your issue is.
    – Milo
    Aug 7, 2011 at 16:33
  • When I log in it sends me to www.example.com/blog/wp-admin/ ... I also been clearing cache every step of the way .. I know this wierd and htaccess rules work fine for non-wordpress part of site, it just for some reason the wordpress is having issues with it :(
    – Alex
    Aug 7, 2011 at 16:46
  • 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. Aug 7, 2011 at 17:05

2 Answers 2

2

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.

0

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.

1
  • I know about this wordpress ability, but My main site is non-Wordpress, wordpress is just a little blog in a blog folder...
    – Alex
    Aug 7, 2011 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.