【问题标题】:php application made using codeigniter framework links are not working使用 codeigniter 框架链接制作的 php 应用程序不起作用
【发布时间】:2013-11-08 16:13:36
【问题描述】:

我在虚拟 PC 中设置了一个 ubuntu 服务器。我将使用 codeigniter 框架创建的 php 应用程序放到 /var/www/sdbl 文件夹中。

现在我可以查看我的应用程序的索引页面。但所有的链接都坏了。

我将这些代码放入 .htaccess 文件中,它位于 /var/www/sdbl 文件夹中。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

同一应用程序在此链接上运行良好 http://3linksit.com/sdbl/

有人可以帮我解决这个问题吗? 提前致谢。

【问题讨论】:

  • 你要去哪个链接不起作用? “不工作”是什么意思?服务器错误/404/什么都没有发生?
  • 我刚刚发现...这个链接有效,但我想删除 index.php 的东西。 localhost/sdbl/index.php/new_userlocalhost/sdbl/new_user这个链接会跳转到404错误页面
  • 你用什么来创建链接? codeigniter 原生的锚函数?
  • @Cameeob2003 - 没找到你
  • @Yasitha 我假设您正在通过<a href="<?php echo base_url(''your/url'); ?>">Your Link</a> 对链接进行硬编码,或者您正在使用<?php anchor('your/link/info'); ?>。这是一个正确的假设吗?无论哪种方式,您是否确保在 config.php 中将 $config['index_page'] = 'index.php'; 设置为 $config['index_page'] = '';

标签: php .htaccess codeigniter ubuntu-server


【解决方案1】:

如果我的问题正确,你想让你的链接正常工作并从 URL 中删除“index.php”。按照以下步骤操作,如果这能解决你的问题,请告诉我。

1) 从位于 config 目录的 config.php 中删除 'index.php' 让它看起来像这样$config['index_page'] = '';

2) 将此添加到 .htaccess 文件中

DirectoryIndex index.php
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

如果您有任何疑问或问题,请告诉我。希望对您有所帮助。

最好的问候, 泽山。

【讨论】:

  • 还是有问题 -rwxrwxrwx 1 root root 156 2013-11-10 05:04 .htaccess 我的htaccess文件权限是这样的。没事吧?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-11
  • 2015-01-05
  • 1970-01-01
  • 2014-09-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多