douke9379 2014-10-09 19:52
浏览 45
已采纳

路由适用于localhost,但不适用于生产服务器

I have a fresh installation of Laravel. It works perfectly fine on my local machine. But on the server the routes doesn't work correctly.

Here's how the URL looks like on my localhost:

localhost/articles/14

But when I try the same URL on my production server it doesn't work. But it does work if I type the URL like this:

mydomain.com/index.php/articles/14

So, with the index.php in between it works fine. And the index route works without a problem. So it seems like some kind of redirect issue.

Here's how my .htaccess file looks like:

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

I tried adding RewriteBase /mypath/ to the .htaccess without luck.

I have searched on Google and tried some suggestion without luck.

  • 写回答

1条回答 默认 最新

  • douraoyw194498 2014-10-09 19:58
    关注

    Check if mod_rewrite is enabled on your server.

    Also, .htaccess may be disabled on your server for security reasons. Try putting your mod_rewrite on your <VirtualHost> or <Directory> section.

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

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?