Support » Fixing WordPress » subdir / symlinks having htaccess authorization get 404?

  • Resolved James Wilson

    (@jrguitar21)


    In another thread i resolved an issue about symbolic links getting eaten by wordpress by adding:

    RewriteCond %{REQUEST_FILENAME} !-l

    to the existing conditions:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    generated for the site root .htaccess by wordpress.

    The situation is only halfway resolved, because for regular symbolic links this indeed works, but if the symlink links to a folder that has its own htaccess that employs authentication, the conditional statement fails.

    This occurs not only with symlinks, but also with a real subdirectory is protected by htaccess auth. Means that the authentication is making real folders, and thus symbolic links to those folders fail the above rewrite conditions.

    Is there a workaround to beat this situation? Obviously quite beyond the scope of just wordpress, this is advanced htaccess voodoo.

    here are two examples I’ve created:

    NOTE: subdir/ is a real sub directory in the site root
    regular-symlink/ links (correctly) to subdir/regular/ folder, and restricted-symlink/ links to subdir/restricted/ folder where i have implemented some .htaccess authentication mechanism. As you can see with the restricted-symlink/ as well as the real folder subdir/restricted/ it gets eaten by wordpress and spit out by the wp 404 not found page. This means it must have slipped through the Rewrite Condition failing to show up as a real directory/link.

    Edit: modified the thread title to correctly represent the thread body and question.

Viewing 1 replies (of 1 total)
  • Thread Starter James Wilson

    (@jrguitar21)

    To close this thread, i will copy what Otto42 responded to my other thread with a solution:

    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 1 replies (of 1 total)
  • The topic ‘subdir / symlinks having htaccess authorization get 404?’ is closed to new replies.