Im working with a lots of project locally. I have set my apache root to refer to my folder containing all of my projects, so localhost simply get me there.
Inside subfolders of localhost (wich is root) i would like to add a rewrite rule so / refers to the PROJECT root, not localhost.
Example of my structure:
localhost/a-very-nice-projekt/
Inside the project I want to file link to root like this src="/img/picture.jpg". It would make it easy to move around folders without the need to change links. It also makes it possible to use php include of my navbar and header as links always refers to project root.
Tried a lot of googling and code but I think I’m a little bit wrong…
I don’t believe you can really do what you are trying to do, at least through .htaccess. In your case localhost is the domain, and the leading slash in the links tells the browser to grab the resource from that path relative to the domain. Different rules in different folders can’t really affect this.
Your best bet is probably to create various virtual hosts on different ports, that would act as separate sites. Create one vhost for each project in your httpd.conf file.
Then, this project would be accessed in your browser as
http://localhost:8081/. All the paths will work as expected and you should be good to go.