Hi,
http://www.aapkapaper.com/
for this url previously i wrote the segment code like this:
$page_name = $this->uri->segment(2);
$controller_name = $this->uri->segment(1);
But now If i have a url like this
http://aapkapaper.com/demo/Baxobeat
then for this url how can i write the segment code, can anyone help for this…
Thanks in advance
dsmIT
June 25, 2012, 8:03am
2
You could use the explode() method to do this combined with the $_SERVER[‘REQUEST_URI’] superglobal. Something like this:
$segments = explode('/', $_SERVER['REQUEST_URI']);
Then, $segments will be an array with all the URL bits in it.
please can you explain this by an example…
dsmIT
June 25, 2012, 8:47am
4
Well, say the REQUEST_URI would be /controller/action. You can then use this to split that up as an array:
$segments = explode('/', $_SERVER['REQUEST_URI']);
array_shift($segments); // The first element will be empty because of the first "/", so strip that off.
After you do that, $sements will be an array like this:
$segments[0] => 'controller';
$segments[1] => 'action';
So you can then take the bits you’re interested in out of the $segments array.
ok, i got it but, how i can do this with my previous code. ya something else…
$page_name = $this->uri->segment(2);
$controller_name = $this->uri->segment(1);
My question is :
if you click on http://www.baxobeat.com/
in this page when you click on Login button it goes to http://www.baxobeat.com/home/logIn link, where home and login are not a directory
but now my question is that when i changed the code file to http://aapkapaper.com/demo/Baxobeat/ site, and after that when i clicking on Login button the page goes to shows http://aapkapaper.com/demo/Baxobeat/home/logIn link and shows 404 error.
so, can you please suggest me that what i do for view the page…
Hi,
Please can anyone help for this…
Cups
June 29, 2012, 3:52pm
8
You are creating a broken link in your html.
<div class="login-btn">
<a href="http://aapkapaper.com/demo/Baxobeat/home/logIn"> </a>
</div>
Find out where that is being generated from.
Yes, i found it in header file, and i.e.
<div class=“login-btn”>
<a href=“<?=base_url()?>home/logIn”> </a>
</div>
The base url is set like this in config.php.
$config[‘base_url’] = “http://aapkapaper.com/demo/Baxobeat/ ”;
What can i do next for this…plz help…