Please describe how to achieve the best structure

Why not put the 'images' folder directly under public_html, and use the base_url()-function, provided by the URL helper? That's the way I use image references in my views:

<img src="&lt;?=base_url()?&gt;images/image1.jpg" width="240" height="9">

Hope that helps,

Cheers, Michiel


I use the same kind of system.
But as I have a language system on my base_url() (which gives me either or ) I use the site_url() method to access files, for example :

&lt;link rel="stylesheet" type="text/css" media="screen" href="&lt;?=site_url().PATH_CSS?&gt;jScrollPane.css" /&gt;
    &lt;link rel="stylesheet" type="text/css" media="screen" href="&lt;?=site_url().PATH_CSS?&gt;styles.css" /&gt;
    &lt;link rel="stylesheet" type="text/css" media="screen" href="&lt;?=site_url().PATH_CSS?&gt;jquery.accessible-news-slider.css" /&gt;

and PATH_CSS is an constant (constant.php) that is pointing to "public/css/".

You could do the same structure, so you avoid rewriting all the time the path (if you have a lot of images)

<img src="&lt;?=site_url().PATH_IMAGE?&gt;image1.jpg" width="240" height="9">

Why not just put a forward slash at the beginning of each image path to make them absolute?

<img src='/images/image1.jpg'/>

Then you can put your images folder at root and it won't matter where your views (or whatever page, for that matter) are located.

By the way, you should start a new thread when you need a problem solved. Hijacking another person's thread makes it more difficult for other people to find answers to similar problems.

Sometimes I also use
&lt;base href="&lt;?=base_url()?&gt;"&gt;

at the top of my view pages. Then when I need an image I just use <img src='images/image1.jpg'/>

[quote author="Michael;" date="1236981174"]Greets m_ologin,

I have found the best overall folder structure to be as follows:

-> /administration
-> /core
-> /system
-> /public_html
-> -> /assets
-> -> -> /css
-> -> -> /images
-> -> -> /js
-> -> /uploads
-> -> /themes
-> -> index.php (points to core)
-> -> admin.php (points to administration)

I have to say I quite like this idea. It keeps all the actual files out of what is visible to the user. Also it means multiple sites can exist which use the same database, but only a single admin area is needed, and its not tied to a single application. I may have to think about this for BackendPro in the future.

I'd like to have all of my images inside the application directory, but want to mod_rewrite them so they look like they are at root. I've been trying on my local machine with no luck. Any help?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^css [NC]
RewriteCond %{REQUEST_FILENAME} !^img [NC]
RewriteCond %{REQUEST_FILENAME} !^js [NC]

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

RewriteRule ^/css/(.*)$ /application/css/$1 [NC]
RewriteRule ^/img/(.*)$ /application/img/$1 [NC]
RewriteRule ^/js/(.*)$ /application/js/$1 [NC,L]

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.