Welcome Guest, Not a member yet? Register   Sign In
Display a Image inside CodeIgniter
#11

[eluser]louis w[/eluser]
Glad we could have helped Smile
#12

[eluser]Muser[/eluser]
[quote author="louis w" date="1204702865"]Why don't you just do it all with mod_rewrite? Why are you going through CI to get to an image?[/quote]

Hi igniters!

How can I do this with mod_rewrite?

I have for example this url:

Code:
/media/imatge/2/gos-ben-parit.gif

and i want mod_rewrite do:

Code:
/imgs/2


/imgs/2 is a gif file

"/imgs" is a folder with images without extension (width, height, name and mime are in a database), and I would like sef url's like:

Code:
/media/imatge/{photoid}/sometext.{extension}
#13

[eluser]Muser[/eluser]
Now I have this and works ok:

Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /tests
  
  RewriteRule ^media/imatges/([0-9]+)/([A-Za-z0-9-]+).jpg?$ imgs/$1  [T=image/jpeg,L]

#  RewriteCond $1 !^(index\.php)
#  RewriteRule ^(.*)$ index.php/$1 [L]  
</IfModule>

But when I uncomment last three lines to get codeigniter work, the first RewriteRule doesn't seems to work and go to code igniter environment.

Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /tests
  
  RewriteRule ^media/imatges/([0-9]+)/([A-Za-z0-9-]+).jpg?$ imgs/$1  [T=image/jpeg,L]
  
  RewriteCond $1 !^(index\.php)
  RewriteRule ^(.*)$ index.php/$1 [L]  
</IfModule>

What I have to do?
#14

[eluser]Muser[/eluser]
Yep!

I got it!

For someone i can help, THIS ONE WORKS:


Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /tests
  
  RewriteRule ^media/imatges/([0-9]+)/([A-Za-z0-9-]+).jpg?$ imgs/$1  [T=image/jpeg,L]
  
  RewriteCond $1 !^(index\.php|imgs)
  RewriteRule ^(.*)$ index.php/$1 [L]  
</IfModule>




Theme © iAndrew 2016 - Forum software by © MyBB