routing and relative urls, htaccess? |
[eluser]Unknown[/eluser]
Hi, I am pretty new to codeigniter and I am setting up a site as follows: www.domain.com/site (main site and baseurl) www.domain.com/site/page (about/help/anything etc) I also want to use the following: www.domain.com/site/item/$id where $id is just a unique product code. So far everything is working well css/javascript/links except on the www.domain.com/site/item/7 (or whatever product id). The css/javascript files are not relative to the domain and therefore not showing. I know I can add <?baseurl?>/css/style.css in the headers etc but I will also need to add that to all my links. For example in the footer I have a "home" link and now I will need to add <?baseurl?>/home to all my links. This is a tedious process. Is there a way maybe through htaccess that I can keep all my links and stylesheets and rewrite the urls so I can just use "/css/style.css" or "/about" etc without using the baseurl? Hopefully that makes sense? Thanks in advance, Kim.
[eluser]tomcode[/eluser]
Welcome ceezar, You can set the HTML tag Code: <base href="<?php echo base_url(); ?>" /> in the header of Your HTML file to use relative URL's for Your assets. I always use absolute links for internal links, that way I can develop with index.php (easier) and decide later if I want to remove it. You can use the divers functions of the HTML helper, see the User Guide, The Config class, too, has methods to offer. |
Welcome Guest, Not a member yet? Register Sign In |