问题
I am trying to deploy a Laravel project onto a share hosting, I've managed to get most of the hard work done but I cannot strip off the /public directory without a Forbidden issue.
The website works and shows same pages for these links
- www.mywebsite.com/test/index.php
- www.mywebsite.com/test/public/
But without the /index.php It returns ->
Forbidden
You don't have permission to access /test/ on this server.
Currently my .htaccess looks like the following.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
</IfModule>
Any ideas?
回答1:
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:
this is the magic script i use (add to the .htaccess
in public_html
)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
回答3:
For me the problem was that my storage folder (and subfolders) didn't have the correct permissions.
If you upload with FileZilla you can simply:
- right click your resources
- go to permissions
- check all the boxes and change the input to 777
Also on my host I needed to change public to httpdocs. But that might be different on your host.
来源:https://stackoverflow.com/questions/25119493/laravel-shared-hosting-htaccess