WordPress.org

Ready to get started?Download WordPress

Forums

Protected Folder on a WordPress site (9 posts)

  1. computergenius
    Member
    Posted 3 years ago #

    I need to create a protected folder inside a WordPress site, for something not directly connected to the WordPress code.

    If I create a folder
    mywpsite.com/myfolder
    it works fine.

    But when I password protect myfolder, using htaccess, I get a 404. Does anyone have any suggestions? Has anyone done this before?

  2. Alok Tiwari
    Member
    Posted 3 years ago #

    Your requests are being handled by .htaccess
    That's why its generating 404

  3. computergenius
    Member
    Posted 3 years ago #

    Yes, thanks for your post, but I understand *why*

    The (WordPress) .htaccess, in the root folder, is trying to re-route to a post with a similar name, which obviously does not exist.

    The only fixes that I have found so far, involve shutting off the 404 and the 403, which isn't really very elegant. I was hoping that someone had a better suggestion.

  4. Alok Tiwari
    Member
    Posted 3 years ago #

    Spend some minutes reading about .htaccess [ Google ]
    You could solve Without changing the exiting setup

  5. computergenius
    Member
    Posted 3 years ago #

    you said:
    >Spend some minutes reading about .htaccess [ Google ]

    I had already said:
    >The only fixes that I have found so far...

  6. Alok Tiwari
    Member
    Posted 3 years ago #

    Anyway..

    modify your .htaccess file by inserting the following code directly after the "RewriteEngine on" directive, before the wordpress rewrites:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} "/YourFolderNameHere/"
    RewriteRule (.*) $1 [L]
    # Rest common WP rules follows below this line

    A elementary level tool to save your time is is available here http://www.lyxx.com/freestuff/002.html

  7. computergenius
    Member
    Posted 3 years ago #

    That is what I had in the first place.

    It worked fine, but it doesn't seem to work when I add the /myfolder/.htaccess with the password protection. If I delete /myfolder/.htaccess, it works fine. But I need the password protection.

    Thank you for the suggestion of the elementary level tool, but I usually have no problem with .htaccess

  8. Alok Tiwari
    Member
    Posted 3 years ago #

    Try This

    .
    .
    RewriteCond %{REQUEST_URI} "/YourFolderNameHere/"
    #RewriteRule (.*) $1 [L]
    #Write your rules (/myfolder/.htaccess) Below this line here
    .
    .
    # Rest common WP rules follows below this line

  9. computergenius
    Member
    Posted 3 years ago #

    That's not going to work, all you have is an "if"

    I have up on the .htaccess route, and protected the pages with session passwords and a PHP login screen.

Topic Closed

This topic has been closed to new replies.

About this Topic