Forums

[resolved] using htaccess to restrict wp-content access from the browser (7 posts)

  1. cristiansans
    Member
    Posted 4 years ago #

    hi,

    i've just been playin g the whole day with the .htaccess file to get the most accurate configuration. my goal is to block the access to the wp-content folder from the browser.

    i'm not so familiar with rewrite rules and i'm not so happy with the result, i think that i can be done in a cleanest way,

    Actually i added a blank index.php files to any folder inside wp-content and write a rule for any of the folders that looks like this:

    Redirect 301 /wp-content/index.php http://mydomain.com/

    I think that this can be done in a better way because this solution doesn't cover the full access to the folders. And when I tried to aply te rule directly to the folder, as you can imagine, some of the plugins that i'm using or even the upload module stop to run because the server is redirecting any request to this folder.

    I was just wondering if someone can point me in the right way.

    Thanx!

  2. whooami
    Member
    Posted 4 years ago #

    you cant do that, for reasons you just discovered. Your themes live inside there, your plugins live inside there.

    You can prevent files that live inside those directories from being called directly -- but it would take editing every file individually.

    You can prevent those directories from being browsable by insuring that you are using Options All -Indexes in your .htaccess -- You can combine that with an index.html, if you like, inside each directory.

    Keep in mind, putting an index.php inside your wp-content/plugins directory will cause issues with your dashboard. Thats why I said index.html.

  3. cristiansans
    Member
    Posted 4 years ago #

    ok I understand i'm going to update my .htaccess and change the .php files for a html ones.

    very helpful!

  4. cristiansans
    Member
    Posted 4 years ago #

    Just to confirm that is running.

    thanx!

  5. whooami
    Member
    Posted 4 years ago #

    whats running? :)

  6. Michael Torbert
    WordPress Virtuoso
    Posted 4 years ago #

    lol

  7. cristiansans
    Member
    Posted 4 years ago #

    yeyeye lol i just added the -Indexes rule.

    how i should do to instead to redirect the content to the main page give the error 404 page?

Topic Closed

This topic has been closed to new replies.

About this Topic