Laravel Shared Hosting.htaccess

I'm trying to deploy a Laravel project to a share hosting, I've managed to do most of the hard work, but I can't seem to disable / public directory without a forbidden problem.

The website works and shows the same pages for these links

  • www.mywebsite.com/test/index.php
  • www.mywebsite.com/test/public/

But without /index.php It returns ->

Forbidden

You don't have permission to access /test/ on this server. 

      

Currently my .htaccess looks like this.

<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ public/index.php [L]

</IfModule>

      

Any ideas?

+3


source to share


2 answers


Try this rule in test/.htaccess

:



DirectoryIndex index.php
<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /test/

    RewriteRule ^$ public/index.php [L]

    RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

</IfModule>

      

+2


source


For me the problem was that my storage folder (and subfolders) did not have the correct permissions.

If you are downloading a FileZilla file, you can simply:



  • right click your resources.
  • go to permissions
  • check all fields and change the input to 777

Also on my host I needed to change the post to httpdocs. But this may be different from your host.

0


source







All Articles