• Resolved Tom Harrison

    (@fivepercent)


    I have a new blog installed in /home/user/blog — the Apache DocumentRoot is set to /home/user, not /home/user/blog — this is intentional (some other code runs out of the document root). When default (ugly) URLs are set, everything works fine, but when pretty permalinks are set, urls like http://domain.com/blog/2009/05/16/my-pretty-permalinked-post/ result in a 404 error.

    The blog homepage comes up ok, and stuff in wp-content is working (images, etc.), and /blog/wp-admin is fine, too. Any other page seems to result in a 404. This leads me to think that requests are getting to ~/blog/index.php correctly, but something in the internal rewriting is unhappy.

    SiteURL and Home are both set to http://domain.com/blog. The .htaccess file in the ~/blog directory is readable and writable by apache and getting updated:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

    I will owe my eternal gratitude to the person who helps me understand how I have messed things up so badly 🙂

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • try adding this to your .htaccess in wordpress root

    Options +FollowSymLinks
    <Directory /www/replace/this/with/actual/directory>
     AllowOverride Options
    </Directory>

    Thread Starter Tom Harrison

    (@fivepercent)

    @samboll

    This gets me closer — I can load the permalink version of the pages, the home page, and the page in the Apache DocumentRoot — thanks! But now it appears that Apache is not finding actual files and directories, so images, css, and wp-admin don’t work.

    I’ll read the Apache manual to figure out what’s going on, but if you have any further advice or thoughts, I would be most grateful.

    I’ll re-post if I find a solution.

    My /home/user/blog/.htaccess now looks like

    Options +FollowSymLinks
    <Directory /home/user/blog>
       AllowOverride Options
    </Directory>
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    
    # END WordPress

    Thanks!!!

    Thread Starter Tom Harrison

    (@fivepercent)

    Ok, so I sorted out my remaining problem with permalinks and subdirectories. Adding the AllowOverride Options in a <Directory /home/user/blog> section was the trick.

    The reason I continued to have problems was that the virtual host configuration was in conflict. It has a <Directory /home/user> section that specified AllowOverride none — this directive prevents the .htaccess file in the blog subdirectory from ever getting evaluated.

    Since I have access to the virtual host config, I was able to specify everything in one place, and eliminated the .htaccess file (as recommended by Apache documentation, for performance reasons). Here is the VirtualHost snippet, which accomplishes the same thing as the .htaccess file:

    <VirtualHost *:80>
        DocumentRoot /home/user/
        ServerName mydomain.com
        ServerAlias www.mydomain.com
    
        <Directory "/home/user">
          Options FollowSymLinks
          AllowOverride none
          Order allow,deny
          Allow from all
        </Directory>
    
        <Directory "/home/user/blog">
          RewriteEngine On
          RewriteBase /blog/
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule . index.php [L]
    
          Options FollowSymLinks
          Order allow,deny
          Allow from all
        </Directory>
    </VirtualHost>

    Note that the RewriteRule specifies . index.php, not . /blog/index.php since it is in the context of the <Directory /home/user/blog> already.

    (There are other things in the virtual host, but these are the relevant ones to my situation. And no, my user is not really user 🙂

    Thanks again, samboll — I owe my eternal gratitude for your help!

    I AM LOST! I have this problem as well, someone help!

    I do not HAVE a htaccess file at all.

    I need some clear instructions what goes where please?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘404 when permalinks turned on with blog in subdirectory’ is closed to new replies.