du1843 2012-04-02 17:31
浏览 36
已采纳

如何为每种语言创建子域?

I want to make website in multiple languages, I do it right with cookies to detect the user preferred language.

Now I want to make each language has its sub-domain to be indexed in search engines, some thing like Facebook.

so I want to configure my Apache to point all my virtual hosts to the same folder, then use $_SERVER["SERVER_NAME"] to figure out what sub-domain was requested.

I start to use this code in my htaccess file:

<VirtualHost *>
    ServerName mydomain.com
    ServerAlias en.mydomain.com ar.mydomain.com es.mydomain.com
</VirtualHost>

but it doesn't work and I get cannot find server when I request es.mydomain.come so any help ?

BTW I use mod_rewrite after that code above! and I didn't create any sub-domain in cPanel!

  • 写回答

2条回答 默认 最新

  • dongyong6428 2012-04-02 17:43
    关注

    You can direct all subdomains to the same folder using a wildcard *

    <VirtualHost *>
          ServerName mydomain.come
          ServerAlias *.mydomain.com
    </VirtualHost>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题