[英]Laravel 4 - 403 Permissions error when trying to access css/js files
I'm running on an Ubuntu 13.10 dev environment with Apache2 and after hours of trying to figure out permission errors to access routes, I was able to fix it. 我在具有Apache2的Ubuntu 13.10开发环境上运行,经过数小时的尝试找出访问路由的权限错误后,我得以对其进行修复。 Now I can successfully browse through my application, but the problem that now exists is that I cannot access my css/js files within my public directory - it kicks back with a 403. 现在我可以成功浏览我的应用程序,但是现在存在的问题是我无法访问我的公共目录中的css / js文件-它以403开头。
I've tried modifying the .htaccess file, the virtual host config file, and ran chmod on the entire site directory. 我尝试修改.htaccess文件,虚拟主机配置文件,并在整个站点目录上运行chmod。
Here's a copy of my .htaccess file within the Public folder: 这是Public文件夹中我的.htaccess文件的副本:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
And here's a copy of my virtual host file: 这是我的虚拟主机文件的副本:
<VirtualHost *:80>
DocumentRoot "/home/casey/Sites/caseyhoffmann.me/public"
ServerName caseyhoffmann.me.dev
<Directory "/home/casey/Sites/caseyhoffmann.me/public/">
AllowOverride all
Require all granted
DirectoryIndex index.php index.html
Options -MultiViews
</Directory>
</VirtualHost>
Any ideas? 有任何想法吗?
Solved. 解决了。 Reapplied chown and redid chmod on the directory. 在目录上重新应用chown和redid chmod。 File system permissions issue and had nothing to do with Apache. 文件系统权限问题,与Apache无关。
Solution 1: (Recommended) 解决方案1 :(推荐)
use absolute path in your css, js, images files rather than a relative one. 在CSS,JS,图像文件中使用绝对路径,而不要使用相对路径。 Which means you have to make sure path of these files start either with http://
or a slash /
. 这意味着您必须确保这些文件的路径以http://
或斜杠/
开头。
Solution 2: 解决方案2:
You can try adding this in your page's header: 您可以尝试将其添加到页面标题中:
<base href="/" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.