Question

i have default controller site.php and there are functions in it. if i want separate controller for new page how can i call it because every time defaulte controller is called what setting should i do for it. I am new to codeigniter

below is my .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /ci_intro
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule> 
Was it helpful?

Solution

I would not set the RewriteBase unless your on a system like Rackspace which requires it. In that case I would set it too /

This is so that it will default to the base directory.

Here is the .htaccess file I use. This way when you go to mypage.com/uri whatever you put as uri is the controller that is called

Options +FollowSymlinks
RewriteEngine on

# On Rackspace and getting 404's? Uncoment this by removing the # :
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_rewrite.c>
   RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top