5

I installed XAMPP and created simple website (a folder 'website' in htdocs folder) that contains a link <a href="/info">Info</a>.

If I type localhost/website in browser I get a default homepage. But if I click the link, it goes to localhost/info (which does not exist), instead of localhost/website/info. I could use <a href="/website/info">, but it would be weird to refactor all the links when changing site name.

So what is the usual setting or solution that people uses when developing sites in XAMPP?

Axel Stone
  • 1,521
  • 4
  • 23
  • 43
  • It is not what I need, I dont want to change the directory where my sites in xampp are stored. – Axel Stone Jan 21 '17 at 12:35
  • Why downvote? It is a clear question. – Axel Stone Jan 21 '17 at 12:37
  • And what if there will be another site alongside my `website` in htdocs folder? – Axel Stone Jan 21 '17 at 12:46
  • That's the only way arround buddy I think basing from your OP. Or you could try manipulating the index.php of htdocs folder and get the request url if it's equal to any of your request then redirect it to your website folder instead – Roljhon Jan 21 '17 at 12:47

1 Answers1

6

You have to change DocumentRoot in httpd.conf file to folder. In your example where you have website directory.

For more sites, you have to have more hosts and then set virtual hosts. Here is link how to do that in Win. But point is the same in all OS.

Hrabosch
  • 1,541
  • 8
  • 12
  • But this would only change the directory where my xampp site folders are stored, no? – Axel Stone Jan 21 '17 at 12:36
  • No, there change document root, so then you will be able to get page by localhost and your a href will work :) – Hrabosch Jan 21 '17 at 12:55
  • Oh I see, but what if there will be more sites alongside my 'website'? There must be a real solution, or do people install new xampp when developing another site? – Axel Stone Jan 21 '17 at 12:57
  • Now I am reading your comments to your question. I think you should clarify about setting document root and accessing via absoluthe/relative links. – Hrabosch Jan 21 '17 at 12:58
  • If you post a link how it could be done I'll accept your answer :) – Axel Stone Jan 21 '17 at 13:44
  • I found post about that for wordpress, but point is same for all webs. Answer updated – Hrabosch Jan 21 '17 at 14:53