<li>Home</li>
that give to me localhost/farmex/localhost/farmex/home
and suppose to be localhost/farmex/home
in routes.php you can set $route['default_controller'] = 'home'; and change your code to
<li>Home</li>
Hope this help! ^^
base_url need to set to get proper link from site_url function.
At your application/config.php you need to set
$config['base_url'] = 'http:/localhost/farmex/';
$config['index_page'] = '';
Remember $config['index_page'] is also important.
If you set
$config['index_page'] = 'index.php';
site_url('home') will produce http:/localhost/farmex/index.php/home
$config['index_page'] = 'index.php?'; will produce http:/localhost/farmex/index.php?/home which is needed sometimes.like if you don't want to use .htaccess file.
Related
i have one problem with function base_url() in my codeigniter.
I'm configure the condeigniter to:
$config['base_url'] = 'sistema_clientes/';
$config['index_page'] = '';
and autoload to:
$autoload['helper'] = array('url');
It's ok, but when i'm try to use base_url('clientes') in my pages, the link repeat.
example, i wanna this : localhost/sistema_clientes/example.
<li>Example</li>
in my url, the link go to: http://localhost/sistema_clientes/sistema_clientes/clientes
but i wanna this: http://localhost/sistema_clientes/clientes
i don't wanna the base_url() repeat the sistema_clientes, please help me.
what i can do to repear this?
Thanks.
Set your base_url like below:
$config['base_url'] = 'http://localhost/sistema_clientes/';
Because setting $config['base_url'] = 'sistema_clientes/'; makes sense that
you are going to sistema_clientes controller so base_url
becomeshttp://localhost/sistema_clientes/sistema_clientes.
I am using rest controller api by phil sturgeon this is the url
paycent/user/index/id/1. Thanks in advance!
you need to set route for that.
set route in your application/config/routes.php file
$route['paycent/user/id/(:any)'] = 'paycent/user/index/id/$1';
Note : If paycent is your project name than remove it from your route. and for creating link you just need to write <?php echo site_url('paycent/user/id/1'); ?>. It will redirect to indexmethod.
In application/config/config.php :
Change
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
I have the following in my codeigniter routes.php file:
$route['default_controller'] = "home";
$route['404_override'] = '';
$route['(:any)'] = "page";
$route['about'] = "about";
$route['content/edit'] = "content/edit";
$route['content'] = "content";
localhost/anything routes to page controller like it should. localhost/about and localhost/content route to the about controller and content controller like they should. But localhost/content/edit routes to page controller. I need it to route to the edit function in my content controller. How do I accomplish that?
Thanks.
Routes will run in the order they are defined. Higher routes will always take precedence over lower ones.
I am guessing this is why it's routing to the page controller.
Try moving;
$route['content/(:any)'] = "content";
Above:
$route['(:any)'] = "page";
I'm using Codeigniter.I want to set href attr to something like :
<a href="/contact.html" >Contact</a>
But i get 404 error because i should write
Contact.
Where is some thing to fix this problem.
Any help please.
Assuming that you have a controller by the name Contact and you successfully extend the CI_Controller class, go to application/config folder and in config.php find:
$config['base_url'] = 'http://www.youdomain.com/';
Then in your internal links you should do:
Contact
If you are using javascript to make the redirect, put on top of the js file:
var host = 'http://www.yourdomain.com/';
Again:
window.location.href = host + 'contact';
If you're using codeigniter, you do not want to point to an .html file.
If you're using codeigniter correctly, you should use the helper methods that exist in codeigniter.
Instead of writing the anchor tag yourself, try this:
<?php echo anchor('contact', 'Contact'); ?>
to add the suffix to your controller in calling go to config/config.php and search for
$config['url_suffix'] = '';
and assign html to it to become
$config['url_suffix'] = 'html';
I have following url:
http://localhost.com/phpdemo/bid/tf/red?
This url redirects through This [ $route['tf/red?'] = "abc/blue" ] to following url:
http://localhost.com/phpdemo/bid/abc/blue
Till now there is no problem. The problem starts when I attach some value with "?" like below:
http://localhost.com/phpdemo/bid/tf/red?a [It always go to default welcome page]
I have tried follwoing routes:
$route['tf/red?(:any)'] = "abc/blue"
$route['tf/red?:any'] = "abc/blue"
$route['tf/red?(a-zA-Z0-9=)'] = "abc/blue"
I have tried following config settings:
$config['permitted_uri_chars'] = 'a-z A-Z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['allow_get_array'] = TRUE;
I also checked by using following:
$config['enable_query_strings'] = TRUE;
Now Iam clueless, what is wrong, either with Codeigniter or myself.
Can some one guide me in this regards.
Thanks in advance
I would look at the value of $config['uri_protocol'] - it is set in the main config.php file and the default is 'AUTO'.
Try each of the possible values to see which works for you - PATH_INFO or REQUEST_URI are common choices.