我创建了Laravel的Web应用程序,这是我laravel服务器(php artisan serve
)上测试过,现在我希望把它放在LAMP这样我就可以进一步测试,但什么是错的。Laravel漂亮的URL和路由不工作的LAMP
当我访问localhost/public/
我得到我的主页,但当我点击我的应用程序内的任何链接时,我得到Not found
错误。另一方面,当我手动输入localhost/public/index.php/someURL
然后我得到链接页面。
有人能告诉我如何解决这一问题?
这是我.htaccess
文件中public
目录:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
</IfModule>
<IfModule mod_deflate.c>
<FilesMatch "\.(html|php|txt|xml|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
这是的Apache2的conf文件的内容(/etc/apache2/sites-available/000-default.conf
):
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/
<Directory "/var/www/html">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我启用了此命令的mod_rewrite:sudo a2enmod rewrite
我使用的是Ubuntu 14.04。
UPDATE:
应用放在里面/var/www/html/
的是,原来的htaccess与Laravel或一些家庭BREW版本捆绑?如果是后者,请考虑尝试使用默认值。 – 2014-11-21 16:59:49
@AndréDaniel默认htaccess只修复了部分问题。现在命名路线的作品,但如果我手动创建链接'/约',那么我再次找不到错误。 – Alen 2014-11-21 17:03:26