首页 > 解决方案 > 将 Laravel 应用程序部署到共享主机后,分页链接错误

问题描述

我使用 ajax 在其框架中加载分页内容。本地主机一切正常。例如,在http://localhost:8000/exampleroute评论部分的分页链接中,第 2 页是:http://localhost:8000/content/page_comments?page=2并且效果很好。

但是在共享主机中是:https://example.com/content/page_comments?%2Fexampleroute=&page=2并且链接不起作用。我猜这个问题与 .htaccess 文件有关。所以 .htaccess 内容在这里:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

什么是基础问题?

标签: phplaravel.htaccesspagination

解决方案


RewriteBase /似乎这可能是问题所在。

删除它并与https://laravel.com/docs/5.6/installation#pretty-urls进行比较。确保在您的.env文件中APP_URL为您的应用程序 url 设置了值。


推荐阅读