Welcome Guest, Not a member yet? Register   Sign In
How does codeigniter allow for friendly urls?
#1

[eluser]Unknown[/eluser]
I am currently working a php website, and I would like to have friendly urls (www.ellislab.com/forums/newtopic/53 instead of query strings (codeigniter.com?action=new_topic...).

I have succeeded in parsing the URI to obtain a matching controller, but when the template tries to load the CSS, it does it incorrectly.

For example, currently if I try to visit "www.example.com/index.php", the template will load the default controller and load the css in "resources/styles/default.css".

But if I try to visit "www.example.com/index.php/blog", it will indeed find the blog controller, but it will also try to load the css from "/index.php/blog/resources/styles/default.css".

I've thought about including the css inside the template, but that defeats the purpose of external css. I know codeIgniter definately has a way around this, and I also know the kind souls here know more about this framework than I do. Anyone care to share your thoughts on getting around this?
#2

[eluser]Ben Edmunds[/eluser]
When you say the "template", what do you mean? Are you using a templating extension?
#3

[eluser]Johan André[/eluser]
Did you check out the tutorials?

Sounds like you somehow managed to get a default install working with querystrings.
That's not even enabled in the default config.

You got friendly urls more or less from the start... IMHO you should not mess around with querystrings if you don't actually need that for the setup.
#4

[eluser]jedd[/eluser]
In your view:
Code:
echo link_tag('assets/stylesheets/COMMON.css');

This forces absolute paths, which is typically what you want. Experiment with this, checking source of the rendered page through your browser. If you want to run them by hand, wrap some HTML around a base_url() call with your path/cssfile.
#5

[eluser]Unknown[/eluser]
Thank you all for your responses, but I think I didn't explain myself clearly. I am not working under CI. I am working on a personal project inspired by CI. One of the things I admire from CI is its ability to use friendly urls. I've figured out how to parse the URI and load the appropiate controller, but when this happens the browser thinks I'm calling the CSS in a directory relative to the URI. At "www.example.com/index.php", the default controller is called and the css is also called correctly at "www.example.com/resources/style/default.css". However, at "www.example.com/index.php/blog/", the controller "blog" is found and loaded, but the css is called incorrectly at "www.example.com/index.php/blog/resources/style/default.css". I am trying to make it so when I make any HREF, it does it from the base url of the website, not from the URI (or URL? Not entirely sure here.) Again, thanks for your responses!
#6

[eluser]jedd[/eluser]
Oh, you probably want http://inspiredbyellislab.com/forums/
#7

[eluser]Colin Williams[/eluser]
It's all there in the source code, Le Havre.
#8

[eluser]n0xie[/eluser]
[quote author="Le Havre" date="1254533765"]I am working on a personal project inspired by CI. [/quote]
Why not just use CodeIgniter...




Theme © iAndrew 2016 - Forum software by © MyBB