1

I have uploaded working codeignter application on public ip for testing. Home page is working fine but other pages are not working.

but i can access inner files as below: http://ip-address/index.php/about-us/who-we-are

My files are as below:

**config.php**

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';


**routes.php**

$route['about-us/(:any)'] = "page/aboutUs/$1";
$route['contact-us/(:any)'] = "page/contactus/$1";
$route['plan-articles'] = "page/planArticles";

$route['(:any)'] = "page/$1";

$route['default_controller'] = "page";
$route['404_override'] = '';


**.htacess**

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond $1 !^(index\.php|assets|fav\.ico|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L] 
</IfModule>
SureshK
  • 123
  • 1
  • 4
  • 17

3 Answers3

1

Issue is there as your project specific .htaccess file is not being called from Apache server.

You have to check in apache httpd.conf whether "AllowOverride All" is active or not.

prashant thakre
  • 5,061
  • 3
  • 26
  • 39
1

I did several projects with CI. Never got a error like that.

use this .htacess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

For Extra Knowledge :

if you bother about your URL and how it looks like, you can use different controllers to each page.

if product page use product controller, if About Us page u can use aboutUs. then your URL look like www.example.com/product/ or www.example.com/aboutUs/.

So each and every controller you can use functions and can do much much. $route is also best method. But this is the most easiest method.

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
0

Create each page as a controller/view Then you can redirect to the controller, which loads the view.

layout example:

application/controllers/main.php
application/controllers/page1.php
application/views/main.php
application/views/page1.php

This might help: How do I get the project basepath in CodeIgniter

Community
  • 1
  • 1
wclark
  • 436
  • 4
  • 14