0

我已经按照http://searchdaily.net/codeigniter-2-smarty-3-integration/将 Smarty 3.1.14 集成到 CodeIgniter 2.1.3 的教程进行操作,当我尝试在它们之间导航时,除了我的链接之外,一切都运行良好我的 smarty 文件转到 ex: http://local.host/project/index.php/Smartytest <- 我需要做的是避免 index.php 并输入为 //local.host/project/Smartytest

在我的测试中它说:

$SCRIPT_NAME 是 /cismarty-new/index.php

我只想隐藏 index.php 以便我可以做 /cismarty-new/Smartytest 例如而不是 /cismarty-new/index.php/Smartytest

谢谢

4

1 回答 1

0

你试过使用 .htaccess 吗?

如果您还没有尝试过,请执行以下操作,看看它是否可以解决问题:

在文件夹的根目录(在 cismarty-new/ 内)创建一个 .htaccess 文件,复制代码并保存。

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

然后打开 codeigniter config.php 并将 $config['index_page'] 留空:

$config['index_page'] = '';

PS:记得检查你是否激活了 Apache 的“rewrite_module”,否则将无法工作。

于 2014-03-19T05:37:56.603 回答