• Resolved pshing

    (@pshing)


    Hi,

    I have encountered a problem about restricting the uploaded media. I have activated AAM in a new wordpress without other plugins, in a testing environment. Then I follow the instruction to create .htaccess at wp-content/uploads folder and enabled “Media Files Access Control” option on the Utilities tab.

    After that, I try to upload a jpeg on the backend media Library using admin role, the file can be uploaded successfully but the image cannot be displayed. Then I try to access the jpeg using the URL directly but I got a blank page as well. I didn’t make any change on AAM setting at this moment so suppose the admin role should be able to access the jpeg by default.

    Later on, I try to remove the .htaccess which located at wp-content/uploads folder and the image can show finally, however, it means that the physical file cannot be protected via AAM control manager.

    Since the testing environment is sharing with other website, i have made some changes in the .htaccess as below:

    # BEGIN AAM Media Access Control
    RewriteEngine On
    RewriteBase /XXX/XXX/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} !(\.css|\.php|\.js)$
    RewriteRule . index.php?aam-media=1 [L] <- Remove the starting ‘/’
    # END AAM Media Access Control

    See if you can give some advises in this case.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi pshing,

    Thank you for the detailed explanation. htaccess always was and will be a tricky part of the website administration. Based on your settings, you defined RewriteBase parameter with already trailing ‘/’ (forward slash). That is why removing leading ‘/’ from the RewriteRule is the probably the right way to go. It all depends how your Apache module is configured.

    It is not clear no me, so when you removed the leading ‘/’ for RewriteRule did everything start working as expected?

    Thank you,
    Vasyl

    Thread Starter pshing

    (@pshing)

    Hi Vasyl,

    Thanks for your reply. It is still not working even I have made the changings in .htaccess. The only way I can work is to remove the .htaccess, but it is meaningless since it have given up the physical file protection.

    Let me try to explain more. I have made two changes on the .htaccess, since my project is hosting in testing environment and it isn’t located under the root of /var/www/html/. My project location –> /var/www/html/XXX/XXX/.

    # BEGIN AAM Media Access Control
    RewriteEngine On
    RewriteBase /XXX/XXX/ <– 1. Set the base path to my sub directory.
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} !(\.css|\.php|\.js)$
    RewriteRule . index.php?aam-media=1 [L] <- Remove the starting ‘/’, try to use wordpress project’s index.php instead of the root’ index.php.
    # END AAM Media Access Control

    Does the plugin only support for the wordpress which is installed under root directory? (/var/www/html/)

    Or how can I revise the .htaccess to make it workable?

    Thanks again,
    pshing

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cannot display upload media after adding .htaccess’ is closed to new replies.