Reputation: 909
This is my current .htaccess:
Options +FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]
My config file:
$config['base_url'] = 'http://localhost/argh/';
$config['index_page'] = '';
And when I click, for example, on the about us link it looks like this:
http://localhost/argh//about
(2 forward slashes between argh and about)
Any suggestion? : )
EDIT:
Not sure, but this looks like a Codeigniter issue, because the function:
function site_url($uri = '')
{
if ($uri == '')
{
return $this->slash_item('base_url').$this->item('index_page');
}
if ($this->item('enable_query_strings') == FALSE)
{
$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
}
else
{
return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
}
}
More precisely here:
return $this->slash_item('base_url').$this->item('index_page');
returns the base_url when:
$config['index_page'] = '';
That's why the previous example ends like this:
http://localhost/argh//about
Upvotes: 4
Views: 3444
Reputation: 1
this work
<a href="<?php echo site_url('Controller_Name') ?>" </a> change to <a href="#" onclick="window.location='<?php echo site_url('Controller_Name'); ?>'"></a>
Upvotes: 0
Reputation: 1304
Just incase someone faces the same problem in the future:
I had the same problem because of the way i was redirecting, for example after successful login I used header("Location:".site_url()."/admin/home");
even after removing index.php
from $config['index_page']=''
i kept getting http://example.com//admin/home
Solution:
Use the redirect()
function that CI provides and not header('');
i.e
Change: header("Location:".site_url()."/admin/home");
to redirect('/admin/home')
Upvotes: 0
Reputation: 548
change this in system -> url_helper.php file
rtrim($CI->config->site_url($uri),'/');
Upvotes: 0
Reputation: 2401
Use this in .htacces file
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Use this for base url
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/argh';
and use path as form action
<form method="post" action="<?php echo base_url();?>Your_Controller_Name">;
for href use this
<a href="<?php echo site_url("Controller_Name/Action_name"); ?>">About Us</a>
Upvotes: 0
Reputation: 3675
Check you aren't writing:
base_url().'/about'
in your queries - base_url() will use the / from your config file
also, remove the second . from this line:
RewriteRule ^(.*)$ ./index.php/$1 [L]
to read:
RewriteRule ^(.*)$ /index.php/$1 [L]
Upvotes: 2