Welcome Guest, Not a member yet? Register   Sign In
[Solved]Problems in URL when using controller/method, please help
#1

[eluser]prince1001[/eluser]
Hi

I'm trying to solve this problem that has kept me going now the whole day!
My site works fine with codeigniter when I use URL's with only the controller.
If I use controller/method I get strange results.

For example:
I use htpp://127.0.0.1/ci --> redirect to homepage http://127.0.0.1/ci/index.php/welcome --> this is OK

In this page I have a link to the page http://127.0.0.1/ci/index.php/forgottenp...gepassword.
When I click this link all my links in the page forgottenpassword/changepassword have the forgottenpassword after the index.php page! The page http://127.0.0.1/ci/index.php/welcome becomes http://127.0.0.1/ci/index.php/forgottenpassword/welcome! So I recieve page not found!

If searched, changed the config file, added the? behind index.php etc...

I found out that if I use anchor(), it works, but links made with <a ></a> have problems. Anybody?
Please help!
#2

[eluser]Crimp[/eluser]
It's hard to say. Your question is a little confusing. This part in the user guide about CI URLs may help: http://ellislab.com/codeigniter/user-gui.../urls.html.
#3

[eluser]cahva[/eluser]
I think I know what you mean. You have links like this in your code:
Code:
<a href="welcome"> Welcome </a>
Its an issue because browser sees you in a different directory so when clicked that link on http://127.0.0.1/ci/index.php/forgottenpassword/, the browser will give you a link of http://127.0.0.1/ci/index.php/forgottenpassword/welcome because its relative.

Either use anchor() which adds your base_url to the links, or you can also set base tag and all your links are relative to that. Example:
Code:
&lt;html&gt;
&lt;base href="&lt;?php echo base_url() ?&gt;"&gt;
#4

[eluser]prince1001[/eluser]
Cahva, you are right! That was the problem. I added the base tag and it is working now.
Thank you very much!




Theme © iAndrew 2016 - Forum software by © MyBB