Protect external WooCommerce links without the need for a plugin [لینک]
Most file download or file sales sites have separate hosts for their download files that are essential to protecting these files; Otherwise, others can make your download host inaccessible. One way to restrict people from accessing your download host is to use external download link protection plugins.
With the searches I did in this regard, I found this method that you can protect your download host links without the need for a special plugin.
1- First, we restrict access to the folder where the download files are located
To do this, log in to your hosting control panel and click on the desired folder and select the change permissions option and set the access to 751
By doing this, when we enter the site address and folder into the browser, the desired folder will not open, but the files inside it will be executed and downloaded
2- In order not to display folders and files when we enter the download host (for example dl.yourweb.com), you can create an html file named index.html and upload it in the public_html folder.
If the html file is empty of code by entering the URL of the download host (for example dl.yourweb.com) a blank white page is displayed
You can use the redirect code to enter the URL, the host will be redirected to your site. In fact, when you open the dl.yourweb.com address with a browser, your main site opens yourweb.com
Put the following redirect code in the index.html file and save it
Note that instead of https://yourweb.com, enter your site address
<head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><meta http-equiv=”refresh” content=”۰; url=https://yourweb.com/”> </head>
Be sure to set the download type to Redirect Only in WooCommerce settings
I hope this article has been useful for you. Please comment on this article