duanguochong0397 2016-04-10 19:30
浏览 65
已采纳

404在AWS EC2上部署laravel时出错

I am trying to deploy Laravel on Amazon EC2 (Linux AMI). I add .htaccess in the larval directory and laravel/public directory.

<IfModule mod_rewrite.c>
WriteEngine On
RewriteBase /laravel/public/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

When I browser the http://www.mydomaine.com/laravel/public, the laravel first page works well, but when I browser into a sub page like http://www.mydomaine.com/laravel/public/login, a 404 Not Found error appears. How to solve this problem, thanks for your help !

  • 写回答

2条回答 默认 最新

  • dtbc37573 2016-04-10 19:39
    关注

    You're doing it wrong. Do no make any changes in a .htaccess file inside a public directory and do not add .htaccess to a Laravel root directory.

    You need to point Laravel to a public directory to make it work. For example, if you've installed Laravel in /path_to_laravel/public/ directory, you need to use these settings in your Apache config:

    DocumentRoot "/path_to_laravel/public/"
    <Directory "/path_to_laravel/public/">
    

    After that restart Apache and your app should work as expected.

    Use URLs, like http://www.mydomaine.com/login without 'laravel' and 'public'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改