eI create link for client to get there pdf bill How can

eI create link for client to get there pdf bill
How can I do to make link impossible to access if someone type address ?
Just have access via site . How must be syntax htaccess ? or 777 code
Thank you

  • Adam Czajczyk

    Hello Laurent_C,

    I hope you're well today and thank you for your question!

    I don't think you could easily achieve this with .htaccess or by setting file/folder permissions.

    With .htaccess you can limit access to the file but this will affect all visitors of the page so e.g. those that should be able to see/download the file will not be able to. Other than this, it may protect hotlinking from other sites but still file will be accessible for everybody coming directly from your site. File/folder permissions work on server level so in order to control access this way you would need to allow users to login to your server e.g. via SSH - that's neither convenient nor safe.

    I think instead you may want to use Membership 2 with "Media Protection" add on that will limit access to files uploaded to WordPress "Media Library":

    https://premium.wpmudev.org/project/membership/

    Then in addition a .htaccess rule preventing direct access/"hot-linking" to the file should complete protection. For example, this rules will prevent direct access to all PDF files from any domain other than "mysite.com" and redirect visitors to Google:

    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpdf)$ https://google.com [L]

    I hope that helps!
    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.