【问题标题】:removing "index.php" from CodeIgniter multiple sub-directories down从 CodeIgniter 多个子目录中删除“index.php”
【发布时间】:2013-01-08 12:10:17
【问题描述】:

我知道这已经被问过很多次了,但是以前的解决方案/答案都不起作用。

我看过这些:

我过去曾成功使用过这些解决方案,但这次安装给我带来了问题。我认为这可能不仅仅是.htaccess 问题。

说明

我的文件夹设置如下:/home/~username~/public_html/~company~/index.php。我的 $config['index_page'] 设置为 "" 并且我的服务器启用了 mod_rewrite。我正在使用CI version, 2.1.3

.htaccess 文件与application 文件夹位于同一文件夹中。

问题

如果应用程序中断,我似乎无法从我的 URL 中删除 index.php。我尝试了很多很多 .htaccess 设置,包括 CI 网站上提供的设置。

我很茫然。如果不是我的.htaccess 文件,它会是什么?如果是我的.htaccess 文件,我做错了什么?我最近的尝试是:

RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.php) [NC]    
RewriteRule ^(.*)$ /home/username/company/index.php/$1 [L] //absolute path
and
""
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ company/index.php/$1 [L]

完整的apache 错误:

[Thu Jan 24 18:22:13 2013] [error] [client ip ] 
File does not exist: /home/username/public_html/company/home

【问题讨论】:

  • 1.你说你“90%肯定”。你可以使用apache_get_modules() 或100% 确定的东西吗? 2. 你的 RewriteRule 缺少 public_html,是故意的吗?
  • 1.我运行了该功能,它确实已安装。 2.我尝试了public_html,没有,没有区别。
  • 您能否发布从 URL 中删除 index.php 时收到的确切错误消息? (它可能在 apache 错误日志或 CI 应用程序日志中。)
  • 我无权访问 apache 日志,CI application/log 只有一个空的 index.html 文件。
  • 这可能与您主机的 apache 设置有关,但如果不看到错误,调试起来会非常困难。

标签: php .htaccess codeigniter


【解决方案1】:

将变量设置为空,如下所示。

$config['index_page'] = '';

尝试用这些参数('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO')一一替换以下变量

$config['uri_protocol'] = 'AUTO';

【讨论】:

  • 用什么.htaccess配置?
  • 与应用程序文件夹在同一文件夹中的那个
  • 什么意思?我想弄清楚我应该使用什么.htaccess 文件设置。
  • 您当前使用的那个似乎适合我,我在这里建议的解决方案“我似乎无法在应用程序中断的情况下从我的 URL 中删除 index.php”
猜你喜欢
  • 2012-05-19
  • 1970-01-01
  • 1970-01-01
  • 2011-10-09
  • 2016-07-13
  • 1970-01-01
  • 2016-01-16
  • 2015-09-06
  • 2014-09-20
相关资源
最近更新 更多