【问题标题】:Removing index & controller from URL Codeingiter从 URL Codeigniter 中删除索引和控制器
【发布时间】:2014-11-10 14:51:50
【问题描述】:

我正在创建一个小型网站,并希望从 URL 字符串中删除 index.php 和欢迎控制器。我的 mod_rewrite 看起来像;

<IfModule mod_rewrite.c>

 RewriteEngine On
 RewriteBase /

 // remove index.php / welcome

</IfModule>

我的应用程序看起来像;

index($pagename){

//pull from database where page name is $pagename
// get head, insert $pagename, insert footer etc


}

【问题讨论】:

标签: php codeigniter mod-rewrite


【解决方案1】:

要删除 index.php,请使用以下代码更新您的 .htaccess 文件:

 RewriteEngine on RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f 
 RewriteCond %{REQUEST_FILENAME} !-d 
 RewriteRule ^(.*)$ index.php?/$1 [L]

希望它能在删除 index.php 时起作用

【讨论】:

  • 请在 config.php 中添加说明以将 $config['index_page'] = 'index.php' 更改为空字符串。
  • 只删除 index.php like $config['index_page'] = ' ';
  • 我要求您更新您的答案,这样就涵盖了所有情况。 :)
猜你喜欢
  • 2012-11-23
  • 1970-01-01
  • 2016-11-02
  • 1970-01-01
  • 2023-03-04
  • 2011-08-04
  • 1970-01-01
  • 2018-01-10
  • 2014-12-16
相关资源
最近更新 更多