cakephp - 如何从 url cakephp 中删除 index.php

标签 cakephp url-rewriting

我已经在 Cakephp 2.3 上构建了一个 web 应用程序..在我的 locaLhost 上所有 url 都很好..我可以像这样访问我的 url

http://localhost/Cakephp

但是现在当我将网站上传到服务器的根文件夹中时...我无法像这样访问我的网址

http://www.myweb.com

相反,它可以像这样访问

http://www.myweb.com/index.php/login

我认为可能有问题的是我的 app/webroot 文件夹中的 .htaccess 文件

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

我认为这种index.php导致了问题..因为我不了解.htaccess,所以不知道如何删除它。

如何从我的网址中获取index.php?

最佳答案

那么,应该没问题吧?您已经有 mod_rewrite 了吗?

如果 mod_rewrite 正确加载,.htaccess 文件就位,并且 index.php 仍然出现在链接中,那么很可能是问题使用 core.php 框架配置文件。

问题原因

就我而言,这是 App.baseUrl 配置选项的问题:

Configure::write('App.baseUrl', env('SCRIPT_NAME'));

解决问题

以下是我如何通过注释掉 core.php 中的以下行来解决该问题(以及其他一些带有重定向的问题):

// Configure::write('App.baseUrl', env('SCRIPT_NAME'));

关于cakephp - 如何从 url cakephp 中删除 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17519443/

相关文章:

database - CakePHP - 如何将翻译行为应用于现有数据库?

php - CakePHP 通过 slug 而不是 ID 过滤列表

apache - 在 htaccess 中屏蔽 URL 重写

iis - 使用 IIS URL 重写替换单词

php - 在php中添加一个月

php - 在 cakePHP 的页面顶部显示所有模型验证错误

php - CakePHP i18n - 翻译长文本/字符串 block

c# - 将多个网址重定向到单个网址

iis - 使用 IIS Url Rewrite 2.0 和 ARR 重写自定义标记属性

javascript - window.location 未提供正确的 URL