【问题标题】:Slim 4, why the ajax call succeed but it gives 404 error on cPanel?Slim 4,为什么 ajax 调用成功但在 cPanel 上出现 404 错误?
【发布时间】:2020-06-24 03:25:43
【问题描述】:

所以,它在我的本地上运行良好,但是当部署在 cPanel 上时出现该错误, 答案是完美的.. 但是有 404 状态... 并且在本地它带有 200 状态,因为它应该

所以我假设是一个 .htaccess 的东西

这是我项目根目录中的 .htaccess

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^$ /$1 [L]
   RewriteRule (^[^/]*$) public/$1 [L]
</IfModule> 

这是 my_project/public 中的那个

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^ index.php [QSA,L]
</IfModule>

提前感谢您的帮助

【问题讨论】:

    标签: php api .htaccess http-status-code-404 slim


    【解决方案1】:

    在你的项目根.htaccess文件中试试这个:

    RewriteEngine on
    RewriteRule ^$ public/ [L]
    RewriteRule (.*) public/$1 [L]
    

    这在您的public/.htaccess 文件中:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
    

    【讨论】:

      猜你喜欢
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 2016-10-03
      • 2017-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多