php - Reroute to index with working images -



php - Reroute to index with working images -

i'm working on site want route communications trough index file. have simple test project next architecture:

root- -.htaccess -index.php -icon.jpg

my .htacces follows:

rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l]

this works, can visit www.mysite.com/abc/def/ghi , still index.php page shows.

i can utilize abc/def/ghi retrieving $_server[ 'request_uri' ].

however, lets in index.php:

echo "<img src='icon.jpg'>";

the icon not show because server search in:

www.mysite.com/abc/def/ghi/icon.jpg

instead of

www.mysite.com/icon.jpg

what doing wrong, , how 1 solve problem professionaly?

simply enough, should utilize absolute pathing instead of relative pathing images.

one way resolve define global constant project, like:

define('images', 'http://website.root.domain.com'.'/images/'); or define('images', domain_url.'/images/');

and utilize in output code like:

<img src='<?php echo images;?>icon.jpg'>

and output result in finish & unalterable path like:

<img src='http://website.root.domain.com/images/icon.jpg'>

note i've taken liberty of assuming you'll storing images in own personal directory opposed in main public directory.

php image .htaccess redirect

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -