与htaccess的三级域名 [英] Third-level domains with .htaccess

查看:215
本文介绍了与htaccess的三级域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望做的事情一样,在basecamp.com使用:贵公司的名称将成为一个三级域名,的 http://mycompany.basecamp.com 为例。据我所知,这是(最有可能)制成.htaccess文件和mod_rewrite的基础上,但我不太明白究竟怎么了。请告诉我这是如何实现的?在此先感谢!

解决方案
  1. 创建子目录里面的htdocs: /主机/用户/我的帐户/ htdocs中/ myCompany中或同等
  2. 备份的.htaccess,始终是更好
  3. 添加以下行的.htaccess 文件:

 的RewriteCond%{HTTP_HOST} ^ myCompany中\ .basecamp \ .COM
的RewriteCond%{REQUEST_URI}!^ / myCompany中/?
重写规则^(。*)$ / myCompany中/ $ 1 [L]
 

这将抓住每一个呼叫到第三级域和子文件夹与文件回答

I would like to do a thing like that used in basecamp.com: the name of your company becomes a third-level domain, http://mycompany.basecamp.com for example. I understand that it is (most likely) made ​​on the basis of .htaccess file and mod_rewrite, but I do not quite understand how exactly. Please advise me how it is implemented? Thanks in advance!

解决方案

  1. Create the subdirectory inside htdocs: /host/users/myaccount/htdocs/mycompany or equivalent
  2. Back up the .htaccess , is always better
  3. Add the following lines to .htaccess file:

RewriteCond %{HTTP_HOST} ^mycompany\.basecamp\.com
RewriteCond %{REQUEST_URI}!^/mycompany/?
RewriteRule ^(.*)$ /mycompany/$1 [L]

This will catch every call to the third level domain and answer with files from the subfolder

这篇关于与htaccess的三级域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆