0

I am trying to setup a test server to build websites in. I am using Ubuntu 14.04 with the public_html directory for each of my sites. So when I create a new site, I build a new user on the server and it creates all the necessary items for me (I also use the users directory to store information about that site as well) and I build the site in the public_html directory. To visit that site I go to http://testserver/~username. When I publish the site, it will be moved to a proper web server.

This works great, but when building the site in the public_html directory, all my absolute links must show as

<a href="/~username/page.php">Link</a>

How can I change it so that I can just make a normal absolute link, i.e.

<a href="/page.php">Link</a>

and have it go to the proper page - testserver/~username/page.php?

I can use relative links as a work around, but I prefer using absolute links in my sites.

Ron Butcher
  • 489
  • 7
  • 16
  • This would require you to set your `DocumentRoot` to `/home/username/public_html`, but at the same time limit your host name to a single web site. To employ different *virtual* hosts on one server, refer to http://httpd.apache.org/docs/current/vhosts/name-based.html (assuming you are using Apache). Note this has no relation to [tag:php], and would also rather belong to [sf]. – Lukas Nov 28 '14 at 23:39

2 Answers2

2

Martin is right but you can use links in the way you wrote if you set up a vhost in your local web server with root directory your username folder.

Akis
  • 193
  • 10
1

You can't there part of the Browsers systems

http:// or https:// mean it's a fully qualified URL

/ means from the root of the domain

../ or pages/ relative to the current path of the URL

What i do is setup more subdomains

setup ~username.testserver/ and use each user as a domain. if you have an actual domain you can use the * as an A Record so that you dont have this problem

Barkermn01
  • 6,781
  • 33
  • 83