Mobile app version of vmapp.org
Login or Join
Gail5422790

: Routing and relative paths CodeIgniter and many other PHP frameworks rout URLs, e.g. if default controller is root.php then both URLs will work website.com/ website.com/root if controller has a

@Gail5422790

Posted in: #Codeigniter #Path #Php

CodeIgniter and many other PHP frameworks rout URLs,
e.g. if default controller is root.php then both URLs will work

website.com/
website.com/root


if controller has a function 'login' then this URL is valid

website.com/root/login


This is very handy, but the HTML template that used to work in first example, doesn't work in the second, e.g. this relative path is no longer valid

<link rel='stylesheet' href='stylesheets/style.css'/>


and instead I have to use

<link rel='stylesheet' href='../stylesheets/style.css'/>


Is there a way around it?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

1 Comments

Sorted by latest first Latest Oldest Best

 

@Rivera981

If you make the styleshhet path relative to the rooot directory of the site I would think it would work in both cases, i.e.

<link rel='stylesheet' href='/stylesheets/style.css'/>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme