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]

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 !

图片转代码服务由CSDN问答提供 功能建议

我正在尝试在 Amazon EC2(Linux AMI)上部署Laravel。 我在 larval 目录和 laravel / public 目录中添加 .htaccess

 &lt  ; IfModule mod_rewrite.c&gt; 
WriteEngine On 
RewriteBase / laravel / public / 
RewriteRule ^ index \ .php $  -  [L] 
RewriteRule。  /index.php [L] 
&lt; / IfModule&gt; 

当我浏览 http://www.mydomaine.com/laravel/public ,laravel第一页效果很好,但是当我浏览像 http://www.mydomaine.com/laravel/public/login 这样的子页面时, 404 Not 找到错误。 如何解决这个问题,谢谢你的帮助!

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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'.

    解决 无用
    打赏 举报
  • doudun3040 2016-04-11 00:00

    Doing as Alexey said should make it work. However, if you really want your application to be in this specific path (/laravel/public/), you might add a new directive to your apache conf file.

    Add a ServerName "localhost.app/my/path" and restart your Apache and it should work.

    解决 无用
    打赏 举报