douchui4815 2017-10-09 13:13
浏览 37
已采纳

每条路线在共享主机上显示404消息

I am trying to deploy a laravel application on A2Hosting shared hosting. My document root is: /public_html directory. I uploaded everything from my laravel application except the public folder to the /beta directory of hosting.

And then I uploaded everything from the public directory to the /public_html directory.

In my index.php file, I changed the following two lines:

require __DIR__.'/../beta/vendor/autoload.php';
$app = require_once __DIR__.'/../beta/bootstrap/app.php';

Now I am only seeing the home page of my application correctly. That is, mydomain.com. Any hyperlink followed by mydomain.com is showing a 404 message. In my view files, this is how I am referring to a path:

<a href="/login">Login</a>

But after deploying the application, whenever I hit that link, i.e. mydomain.com/login, I get the 404 Not Found: The resource requested could not be found on this server! message. I tried changing /login to login in the <a> tag. Same result. How do I solve this?

  • 写回答

1条回答 默认 最新

  • duanmi8349 2017-10-09 13:20
    关注

    Eisenheim, this is htaccess issue: get one .htaccess file in root folder of your web-project.

    And put the following code inside it,

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
    
        RewriteEngine On
    
        # Redirect Trailing Slashes...
        RewriteRule ^(.*)/$ /$1 [L,R=301]
    
        # Handle Front Controller...
         RewriteCond %{REQUEST_FILENAME} !-d
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteRule ^ index.php [L]
    </IfModule>
    

    Then try without index.php it should work perfectly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路