CodeIgniter Forums
htaccess css path relative to index.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: htaccess css path relative to index.php (/showthread.php?tid=58486)



htaccess css path relative to index.php - El Forum - 06-15-2013

[eluser]Unknown[/eluser]
I run CodeIgniter on local LAN.
Since I have Wordpress, Drupal,... and they should not conflict I need to run them as subfolder. For example:
http://192.168.1.101/CodeIgniter/
My css is placed in:
http://192.168.1.101/CodeIgniter/css/mystyle.css
In my PHP styles are addressed:
<?='<link href="css/mystyle.css" rel="stylesheet" type="text/css" />'?>
My problem is that as far as I load index.php there would be no problem. However, when I load a page with parameters like:
http://192.168.1.101/CodeIgniter/users/login
My browser looks for the style in relative way!
http://192.168.1.101/CodeIgniter/[b]users/css/mystyle.css[/b]
Which has an extra users in path.
I want all CSS to be adjusted in relative to:
192.168.1.101/CodeIgniter/

this is the content of 192.168.1.101/CodeIgniter/.htaccess :
Code:
RewriteEngine on
#RewriteBase /
RewriteCond $1 !^(index\.php|image|css|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

how to fix it?

thanks



htaccess css path relative to index.php - El Forum - 06-15-2013

[eluser]Syllean[/eluser]
Code:
<?='<link href="'. base_url() .'css/mystyle.css" rel="stylesheet" type="text/css" />'?>