doulue1949 2014-11-28 23:33
浏览 234
已采纳

在public_html文件夹中创建主目录的绝对链接

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.

  • 写回答

2条回答 默认 最新

  • doucang6739 2014-11-28 23:36
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀