How to restrict direct access
/pub with the project URL (www.domain.com/pub) in
You should make your web server to point to the pub folder directly.
Assuming the web server root is
/var/www/html, and the magento itself is in a folder named
yourmagento, in Apache this can be done like
<VirtualHost *:80> ServerName yourdomain.com DocumentRoot /var/www/html/yourmagento/pub </VirtualHost>
The chances are that the current path for the
Please check with your own server configuration. For nginx the syntax is slightly different, the root folder of the web server can be completely different, but the idea will be the same:
Make the web server to point directly to the /pub folder, not the magento root folder.
And yes, once the configuration is saved, make sure you restart all needed services, and re-deploy static content of Magento.
I think you can block the url in robots.txt