msinfo msinfo - 3 months ago 15
PHP Question

Hosting Codeigniter site on GoDaddy with shared hosting

Directory structure (

public_html
)

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


Configuration file looks like this:

$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
file

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


route.php


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


Under
application->controllers
I have two PHP files,
welcome
and
about
with methods in them.

Below are the links I am generating, which are

<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>


If I manually type
http://www.example.com/index.php/welcome/second
, I can access the page.
But I don't know how to generate the links for the same, and how to get rid of
index.php
in the URL.

Answer

It's better to use the Anchor function for generating links. See documentation here.

The htaccess should remove the index.php before the url, and you should change this line to:

 $config['index_page'] = '';