1

I'm working in a serie of pages that (in the server) will live in a subdomain like this:

http://sub.domain.com

And I'm developing locally here:

http://localhost/subdir/

Inside this /subdir/ I have an /img/ directory with all the common images for my site (logo, background, etc.)

And inside /subdir/ I have pages like this:

http://localhost/subdir/page1/

http://localhost/subdir/otherdir/page2/

And I'm using a header.php for all my pages, then I'm calling it for every page with an 'include'.

In this header I call the image logo like this:

<img src="/img/logo.jpg">

The problem is that with this path I'm calling to the Root Directory that in the server is sub.domain.com and locally is localhost.

Then if I call the image like this works in server but not locally:

<img src="/img/logo.jpg">

And if I call the image like this works locally but not in the server:

<img src="/subdir/img/logo.jpg">

And I want to create a .htaccess file that lives only locally to redirect the Root Directory from localhost to localhost/subdir

I'm seen some solutions inside the httpd.conf in Apache but the problem is that I don't want tho change this root because I'm using different subdirs from different projects as:

localhost/subdir1 <= Project 1

localhost/subdir2 <= Project 2

My question is how to redirect this Root Directory using the .htaccess to make this image calls works in the server and locally?

Of course I was looking and trying but I cant find the solution in other questions here or in othes sites.

Thanks in advance.

0 Answers0