在 GoDaddy 上托管 Codeigniter 网站,使用共享主机


Hosting Codeigniter site on GoDaddy with shared hosting

目录结构 ( public_html

public html
htpasswds
application
    .htacess
cgi-bin
system
user_guide
index.php

配置文件如下所示:

$config['base_url'] = 'http://www.example.com/index.php/';
$config['index_page'] = 'index.php?';
$config['uri_protocol'] = 'AUTO';
$config['allow_get_array']      = TRUE;
$config['enable_query_strings'] = FALSE;

.htaccess文件

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

route.php

$route['default_controller'] = 'welcome';

application->controllers下,我有两个PHP文件,welcomeabout其中包含方法。

以下是我正在生成的链接,它们是

<li><a href='./welcome'>Home</a>
<li><a href='./welcome/first'>first</a></li>    
<li><a href='./welcome/second'>second</a></li>
<li><a href='./third'>Third</a></li>
<li><a href='./fourth>Four</a></li>
<li><a href='./five'>Five</a></li>
<li><a href='./six'>Six</a></li>

如果我手动键入http://www.example.com/index.php/welcome/second,则可以访问该页面。但是我不知道如何生成相同的链接,以及如何摆脱URL中的index.php

最好使用 Anchor 函数来生成链接。请参阅此处的文档。

htaccess 应该在 url 之前删除索引.php,您应该将此行更改为:

 $config['index_page'] = '';