Role based folder access restriction in wordpress website

  • Unknown's avatar

    I hope you had a great day yoday !

    I’m unsuccessfuly trying to restrict access to non logged-in users on a wordpress website :( I have some html documentations pages inside wp-content/uploads/documentations that I would like to lock for a specific role inside wordpress.

    I’m using ultimate member plugin to manage users and roles and lock specific post/pages to certain roles, but I can’t control the access to the direct link of the documentation. A non logged-in user can’t access the member page, that is properly working, but he still can access the documentation through the direct link if someone else give him the link (like http://website.com/wp-content/uploads/documentations/product/index.html)

    I tried to restrict access with plugins, or .htaccess redirection :

    RewriteCond %{REQUEST_FILENAME} -s
    RewriteRule ^wp-content/uploads/documentations/product/(.*)$ dl-file.php?file=$1 [QSA,L]
    and dl-file.php with like : if not logged-in = no access to wp-content/uploads/product/* Details here : [https://carlofontanos.com/restrict-access-to-wp-contentuploads-when-user-is-not-logged-in/][1]

    This cause HTTP 500 error even if I’m logged-in so this is not a good stable solution for me. If I comment the .htaccess redirect lines, no HTTP 500 but everyone can access it.

    I tried other things without success and I’m out of ideas…

    As I am alone in this project, and web dev isn’t my job or my area of expertise, I hope finding help and ideas here to provide a proper solution for my needs.

    I didn’t find a solution for now browsing other posts here.

    Thank you in advance ! Regards, Flynn Provider : OVH WordPress : 5.7.2 PHP : 7.4 DB : MySQL 5.7

  • Hello, I’m sorry to hear that you are having trouble with your website. However, your site is not hosted with WordPress.com. It is a site using the open-source WordPress software (from WordPress.org) but hosted with OVH.

    Because WordPress.com and WordPress.org are two entirely separate entities, we cannot access files or data for sites that are hosted elsewhere, so WordPress.com staff can only assist with sites that are hosted on our servers. You can find more information here about the differences between WordPress.org software and WordPress.com: https://wordpress.com/support/com-vs-org/

    https://wordpress.org/support/ is a great resource for sites using the open source WordPress.org software, and you can find support for that at: https://wordpress.org/support/forums/

    And, you can find support for Ultimate Member at https://wordpress.org/support/plugin/ultimate-member/

  • The topic ‘Role based folder access restriction in wordpress website’ is closed to new replies.