使用codeigniter时,我遇到了一些困难。这是关于URL中的index.php文件。在CodeIgniter的URL中禁用index.php
CodeIgniter服务于所有使用index.php
的页面。所以,我们的网址应该像下面:
http://www.example.com/codeigniter/index.php/something
我想通过编辑config.php
文件,并创建一个.htaccess文件删除从URL中index.php
。从
$config['index_page'] = 'index.php';
改变配置来
$config['index_page'] = '';
之后我能够没有的index.php就这样跑我的项目:
http://www.example.com/codeigniter/something
所以,现在,该链接工作 - 但它也适用于index.php
片段。我也可以看到地址为http://www.example.com/codeigniter/index.php/something
的组件。
我的.htaccess文件是:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
现在,我想让我的网站只提供没有链接中index.php
。我不希望这个网站与链接中的index.php文件一起运行。我想要http://www.example.com/codeigniter/something
完美运行,并且http://www.example.com/codeigniter/index.php/something
不能运行。我怎样才能做到这一点?
可以粘贴您的虚拟主机的配置? – Mauro
对不起,什么是vhost配置?我正在使用xampp在localhost中托管我的项目 – user2849692