CodeIgniter Forums
HMVC and Codeigniter problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: HMVC and Codeigniter problem (/showthread.php?tid=60140)



HMVC and Codeigniter problem - El Forum - 01-24-2014

[eluser]salvomil[/eluser]
Hi everybody,
I started to use hmvc for codeigniter, and I have a problem when I try to display images in views.

Maybe I don't know exactly how to set the configuration.

My structure is the following:

..
-application
--modules
-- mymodule
-- controllers
-- views
-- ecc...
-system
-images
--site
-image.jpg
-bla-bla-bla

When I use controller in my module (http://localhost/codeigniter-hmvc/mymodule/welcome) it is all ok I can view the template and also orm datamapper is ok, but if I need to show an image, ie (http://localhost/codeigniter-hmvc/images/site/image.jpg) I can't see the image, I get error 404 page not found.

Someone could help me?

Thank you


HMVC and Codeigniter problem - El Forum - 01-24-2014

[eluser]noideawhattotypehere[/eluser]
What your htaccess looks like? (the one in root folder, where index.php is, also is there any htaccess in your images folder?)


HMVC and Codeigniter problem - El Forum - 01-24-2014

[eluser]salvomil[/eluser]
Thank you for the answer,

I have to specify I used Codeigniter-skeleton 2.0.
I have no .htaccess in image folder, and there is only .htaccess in root folder , the following:


RewriteEngine on

#Any HTTP request other than those for index.php, assets folder, files folder and robots.txt
#is treated as a request for your index.php file.

RewriteCond $1 !^(index\.php|assets|files|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]


HMVC and Codeigniter problem - El Forum - 01-24-2014

[eluser]salvomil[/eluser]
OK I found the problem thanks to noideawhattotypehere.

In my .htacces there was no "images"
and I added it so from
RewriteCond $1 !^(index\.php|assets|files|robots\.txt)

I modified the line to

RewriteCond $1 !^(index\.php|assets|files|images|robots\.txt).

Thank you.


HMVC and Codeigniter problem - El Forum - 01-24-2014

[eluser]noideawhattotypehere[/eluser]
Ur welcome, glad i could help you


HMVC and Codeigniter problem - El Forum - 02-02-2014

[eluser]student101[/eluser]
Should this be standard for all?

[quote author="salvomil" date="1390561729"]OK I found the problem thanks to noideawhattotypehere.

In my .htacces there was no "images"
and I added it so from
RewriteCond $1 !^(index\.php|assets|files|robots\.txt)

I modified the line to

RewriteCond $1 !^(index\.php|assets|files|images|robots\.txt).

Thank you.[/quote]


HMVC and Codeigniter problem - El Forum - 02-02-2014

[eluser]jonez[/eluser]
If you use an .htaccess like this it won't rewrite real files so if you ever add other asset folders you won't have to change your rewrite:
Code:
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]



HMVC and Codeigniter problem - El Forum - 02-02-2014

[eluser]student101[/eluser]
Thanks I'm still learning Codeigniter and my .htaccess knowledge is from perishablepress

[quote author="jonez" date="1391367856"]If you use an .htaccess like this it won't rewrite real files so if you ever add other asset folders you won't have to change your rewrite:
Code:
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
[/quote]