Reputation: 337
There is one controller in my project called Welcome in that there are two functions, one is index() which load the home page called interior and the other function is architect() which loads the architect page.
<a class="catname activecat" href= "<?php echo base_url(''); ?>">Interior</a>
<a class="catname" href="<?php echo site_url('welcome/architect'); ?>">Architect</a>
The problem is welcome/architect is not working and it is not going to the architect page.
My Welcome controller has the following codes:
public function index()
{
$this->load->model("Interior_listing_model","interior");
$articles = $this->interior->interior_list();
// Load Interior Listing View
$this->load->view("interior/interior",["articles"=>$articles]);
}
public function architect()
{
$this->load->helper('url');
$this->load->model("Interior_listing_model","interior");
$articles = $this->interior->architect_list();
// Load Interior Listing View
$this->load->view("architect/architect",["articles"=>$articles]);
}
Upvotes: 0
Views: 6185
Reputation: 2249
Try this,
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
HTML:
<a href="<?php echo site_url('about-us'); ?>"
Config/Routs.php
$route['about-us'] = "welcome/aboutus";
Controller function
public function aboutus()
{
$this->load->view('about');
}
Create about.php
Hope this will help you!
Upvotes: 0
Reputation: 182
Change like this..
<a class="catname" href="<?php echo base_url();?>/welcome/architect">Architect</a>
Diffference between base and site url:
echo base_url(); // http://example.com/website
echo site_url(); // http://example.com/website/index.php
I think your htaccess is a problem
Steps To Remove index.php using .htaccess:-
Step:-1 Open the file config.php located in application/config path. Find and Replace the below code in config.php file.
// Find the below code
$config['index_page'] = "index.php"
// Remove index.php
$config['index_page'] = ""
Step:-2 Go to your CodeIgniter folder and create .htaccess file.
Path:
Your_website_folder/
application/
assets/
system/
user_guide/
.htaccess <--------- this file
index.php
license.txt
Step:-3 Write below code in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Step:-4 In some cases the default setting for uri_protocol does not work properly. To solve this issue just open the file config.php located in application/config and then find and replace the code as:
// Find the below code
$config['uri_protocol'] = "AUTO"
// Replace it as
$config['uri_protocol'] = "REQUEST_URI"
Upvotes: 1
Reputation: 123
In your config.php
, $config['base_url'] = '127.0.0.0/newbluemasons/';
In your routes.php
, $route['default_controller'] = 'welcome';
Try this, I'm already did some experiments..
<a href="<?php echo base_url().'/' ?>">Interior</a>
<a href="<?php echo base_url().'index.php/architect' ?>">Architect</a>
Upvotes: 0