[英]Laravel assets, routes and pages
我认为这很容易,但是我真的很困惑。
因此,因此,我认为我必须将对myproject.com的每个请求重新路由到myproject.com/index.php
app / config / app.php:
'url' => 'http://127.0.0.1/public',
etc / httpd / conf / httpd.conf:
<VirtualHost *:80>
DocumentRoot "/var/www/html/myproject/public/"
ServerName myproject.com
</VirtualHost>
主机文件中未配置任何内容。
目标 :如何通过隐藏用户的index.php部分将所有请求从myproject.com重新路由到myproject.com/index.php ?
访客应该看到:myproject.com,但我希望他们实际到达:myproject.com/index.php
解决方法:
<VirtualHost *:80>
DocumentRoot "/var/www/html/myproject/public/index.php"
ServerName myproject.com
</VirtualHost>
结果:我无法使用404到达资产(js,css文件)结果,因为不允许我的浏览器访问myproject.com/public/ 。 在此virtualhost设置中,根目录已设置为myproject.com/public/index.php 。
检查您的公共目录中是否存在.htaccess文件。
如果没有,请检查“ 漂亮网址”部分。
还要确保在安全方面将<Directory>
指令放在vhost配置中。
例如:
<Directory "/var/www/html/myproject/public/">
AllowOverride All
Allow from All
</Directory>
关于'url' => 'http://127.0.0.1/public',
中的/public
非常确定。
'url' => 'http://127.0.0.1',
应该可以正常工作。
您需要为此重写规则:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Laravel文档: http ://laravel.com/docs/5.1#pretty-urls
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.