• Resolved James Wilson

    (@jrguitar21)


    I have wordpress functioning from the site root but living in a subdirectory called /wp/ (setup through following the instructions in the codex for Giving WordPress Its Own Directory). My webhost provides a service for each domain at a subfolder stats/ but this and other existing symbolic links found in the site root folder (for example contadores/) are getting eaten (i believe) by the mod_rewrite conditions in the root folders .htaccess (copied from the wordpress directory per codex instructions), and spit out in the wordpress 404 page as not found. Interestingly a real subdirectory works fine and does not get sucked into the wordpress rewrite.

    Trying (in vain) to hack up htaccess with stuff like Options +FollowSymLinks but it doesnt seem to work.

    is there such thing as a RewriteCond for symbolic links that i could plug in with the following wp generated code?:


    RewriteEngine On
    RewriteBase /wp/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    >>> code for "if request filename is not a valid symlink" here
    RewriteRule . /index.php [L]

    Thanks for your help.
    james

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Sure. Add this to those conditions (after the -f and -d):

    RewriteCond %{REQUEST_FILENAME} !-l

    That checks for symbolic links and will prevent WordPress from rewriting when the symbolic link exists.

    After doing this, you’ll want to change your .htaccess file to be read only (chmod 444) so WordPress won’t try to overwrite your changes.

    Thread Starter James Wilson

    (@jrguitar21)

    in case you need it for reference, my complete .htaccess file looks like this:

    `
    Options +FollowSymLinks

    # BEGIN FAlbum
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^photos/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?$ /wp/wp-content/plugins/falbum/wp/album.php?$1=$2&$3=$4&$5=$6&$7=$8 [QSA,L]
    </IfModule>
    # END FAlbum

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

    # END WordPress
    `

    Thread Starter James Wilson

    (@jrguitar21)

    woah, that was quick, thank you very much!

    how did you learn htaccess? you have a link to the apache tutorial that will end all suffering for me?

    Thread Starter James Wilson

    (@jrguitar21)

    @otto: “After doing this, you’ll want to change your .htaccess file to be read only (chmod 444) so WordPress won’t try to overwrite your changes.”

    wordpress will reach into my root dir to change the .htaccess even though it sits in a subdir?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Depends on your particular configuration, but it is possible, yes.

    As for learning mod_rewrite, I just use the documentation:
    http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

    Or http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
    if you have an older 1.3 version of Apache running. Not many differences though.

    Thread Starter James Wilson

    (@jrguitar21)

    not sure if i should post here, or create a new thread, but i discovered that adding the RewriteCond for symbolic links does not work if linking to a folder that has its own .htaccess with authentication built in.

    any help or suggestions on this one?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    The problem with using subdirectories with authentication is a known issue. A workaround is to create an empty file somewhere called “onerror.html” and then to add these lines to the main .htaccess, before the WordPress rules:

    ErrorDocument 401 /path/to/onerror.html
    ErrorDocument 403 /path/to/onerror.html

    Change the path as appropriate for your setup, of course.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘wp htaccess in subdirectory eats symlinks in root’ is closed to new replies.