douding7189 2013-06-19 09:17
浏览 58
已采纳

在apache中获取URL的一部分

I have set wildcard vhosts in my apache like

<VirtualHost *>
  ServerName wildcard.test.com
   ServerAlias *.test.com

   DocumentRoot = /var/www/test
   # other configuration for this app here

</VirtualHost>

I have created some sub domains like front.test.com and admin.test.com. I just want to know if there is a way in APACHE to get the first part of the URL like in above cases, I want test and admin and send it to my server side language some how. I repeat that I am looking for a possible way in apache, as people always say

you can not always trust what $_SERVER returns I will go for server side after confirming that there is not any way doing it on apache Thanks

  • 写回答

1条回答 默认 最新

  • drutjkpsr67393592 2013-06-19 09:27
    关注

    $_SERVER can be trusted. Everything in $_SERVER is 'true'. But that doesn't say you should trust it. It holds the Query_String, HTTP_HOST, ... and these come from a request the user made. It is the user that shouldn't be trusted.

    If a person types in foo.test.com then 'foo.test.com' will be the value of $_SERVER['HTTP_HOST'];

    So I don't really see what the problem is.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程