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 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)