Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter - problem with URLs
#1

[eluser]darkcyde[/eluser]
Hi....I'm trying to get a site up and running utilising CodeIgniter and Ion Auth.

I'm a new user, but an ancient programmer having learnt and programmed in basic and pascal, and all those groundbreaking languages, so I'm not completely green, just a little faded :-)

Ok, so here's what I have....a simple page with a menu at the top, built up with a template page and various content pages depending on what you select from the menu.

Here's the problem.....in routes, if I just declare...
$route['blog'] = 'home/view_blog';
...then it all works as expected. But if I declare...
$route['blog/article'] = 'home/blog_article';
...then all of my URL links then have blog inserted in them.

For example, what would have been...
www.example.com/home
...now becomes...
www.example.com/blog/home
.....which obviously won't go anywhere.

I have tried covering that with another route but it just compounds the problem by making it...
www.example.com/blog/blog/home.

Any ideas? If I just stick with single word routes, then all is fine, but as soon as i try multiple levels of routing, then this happens.

Thanks in advance for any help anyone can give.....I've been working on this all blooming week now. The single level workaround is possible, but obviously not ideal.
#2

[eluser]noideawhattotypehere[/eluser]
"longest" url at the top.
#3

[eluser]darkcyde[/eluser]
You mean in the list of routes, the route with the longest url (most number of slashes) to go first in the list?

If so, I've tried that and it made absolutely no difference.
#4

[eluser]darkcyde[/eluser]
I can bury the files in as many sub folders as I like physically in the file structure, but if I try multiple slashes in the routes address URL, the first word in the URL gets repeated every time.

So I can refer to all my pages with single words, or words separated with underscores, but not forward slashes.

Perhaps it has something to do with the .htaccess file and the rewriting of the URL.....I have tried many different configs in the .htaccess file, and nothing seems to make any difference.

If I try including the index.php in the URL, everything still works, but you still get the additional word in the URL. So...
www.example.com/index.php/home

linking to

www.example.com/index.php/blog/articles

....loads up the page fine, but then every link becomes...

www.example.com/index.php/blog/home

In the page source, there is nothing appended there....the hrefs are still single words, like 'home', but when you hover, the full address is shown with the additional word embedded. Which is why I think it's something to do with the rewrite engine rather than code igniter code.

Also, I've tried submitting a form using the Code Igniter form helper, and the submission url has now become from the original page...

www.example.com/login

to

www.example.com/login/www.example.com/login

This is seriously driving me nuts!!
#5

[eluser]darkcyde[/eluser]
I've been getting around this problem until now, but now I've hit a problem which means I've got to deal with it.

Has ANYONE got any suggestions? I can't believe I'm the only one!

Please, please!! I don't want to have to give up and throw away many hours of work!!
#6

[eluser]darkcyde[/eluser]
Ok, not to worry....have found out myself.

Here's what I did for anyone else having the same issues...

Whenever you create a local URL link, use the following...

Code:
<a href="&lt;?=site_url('link_page');?&gt;">Link</a>

This seems so obvious now, but believe me when your new to all this, it's not so obvious.




Theme © iAndrew 2016 - Forum software by © MyBB