Question

I'm having a problem with denying access to the root directory of my Laravel Site...

I have my project in xampp/htdocs/laravel

Of course Laravel routes the /public directory...

But how can I deny access to the directory xampp/htdocs/laravel ...? How can I prevent the directory listing?

The only way I've found is putting an index.php with a header("location: /laravel/public")

But I dont know if it's the best way... should I use .htaccess? How? I've tried a few but it results in major errors across the server.

Was it helpful?

Solution

You need to open your httpd.conf file (xampp/apache/conf/httpd.conf) and change the "DocumentRoot" value to include the path to your public folder:

DocumentRoot "C:/xampp/htdocs/laravel/public"

OTHER TIPS

Or just add a .htaccess with :

RewriteEngine On 
RewriteRule ^ public [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top