年年我发



返回   年年我发 > 网站建设 > 建站交流
用户名
密码
 
注册账号 论坛帮助 会员列表 日历事件网赚工具 标记版面已读

建站交流 讨论网站建设的基本方法、技巧、空间问题讨论、域名交流、
资源分享、技术交流,站长们经常进来看看噢!
注意:不要留下你的网站链接!

回复
 
主题工具 搜索本主题 显示模式
  #1   IP: 222.184.115.77
旧 2007-08-18, 01:39 AM
smiling smiling 当前离线
高级会员
 
注册日期: 2006-02-12
帖子: 528
现金: 3821 元
资产: 3821 元
声望: 10 smiling 正向着好的方向发展
默认 Multisite configuration

I have a main website of example.com, and I want to add a second (and more) domain named example2.com, with a home directory of example.com/example2/
example2.com is a "parked" domain name, ie it is initially directed to the public root directory of example.com, the main account.

I am told I need.htaccess coding that will

1. set the public root directory of example2.com to example.com/example2/

2. retain the visible url of example2.com *after* internal redirection to example2's public root directory

So the user types example2.com, is taken to the public root directory of example2.com (through.htaccess programming), sees example2.com in the URL field of the browser, but in fact has been taken "underneath" to example.com/example2.

Can anyone show me how this is done, or point me to some documentation?

Thanks!
回复时引用此帖

wellcome to www.0058.net
  #2   IP: 222.184.115.77
旧 2007-08-18, 01:39 AM
smiling smiling 当前离线
高级会员
 
注册日期: 2006-02-12
帖子: 528
现金: 3821 元
资产: 3821 元
声望: 10 smiling 正向着好的方向发展
默认

You will probably want to use the RewriteCond directive examining the server variable %{HTTP_HOST} to match the names of your various domains, and then if the name matches, do an internal rewrite --not a redirect-- to the subdirectory where that domain's files are located.
If your code is in .htaccess, you will also need to test the requested URL to make sure that you have not previously rewritten the request to the subdirectory. Without this test, your .htaccess rules will loop recursively, until the server or client reaches its maximum redirection limit.

As a simple example, consider:

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

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

This approach is workable for just a few domains, but gets unwieldy for more than a half-dozen or so.

For more than just a few domain-subdirectories, it is best to 'tag' the subdirectories with a common prefix to simplify the anti-looping prevention, and to use back-references to carry the name of the domain into the last part of subdirectory name. Something like:

RewriteCond %{HTTP_HOST} ^(www\.)?(domain1omain2omain3)\.com [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?(domain4omain5)\.net
RewriteCond $1 !dsd_
RewriteRule (.*) /dsd_%2/$1 [L]

Here, the we use "dsd_" as a 'tag' to identify all domain-related subdirectories, so that the rewrite looping that I described can be prevented; In this example, a request for the page "foo.html" in the domain "widgets.com" (with or without the leading "www.") will be internally rewritten to "/dsd_widgets/foo.html".

Local variable $1 back-references the requested local URL-path (the "filename"), while local variable %2 back-references the requested hostname. Variable %1, referencing the optional "www.", is not used in this example.

Obviously, there are many possible variations on what you might want to do, so these are just two examples to get you started.

Important: Replace all broken pipe "?quot; characters above with solid pipe characters from your keyboard before trying to use this code; Posting on this forum modifies the pipe characters.

For more information, see the documents cited in our forum charter and the tutorials in the Apache forum section of the WebmasterWorld library.

Once you get your code working, then we can discuss how to prevent "/dsd_widgets/foo.html" from showing up in the search engines... :)
回复时引用此帖
回复


当前查看此主题的会员: 1 (0 位会员和 1 位游客)
 
主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

论坛启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
论坛跳转

相似的主题
主题 主题作者 版面 回复 最后发表
Where can I change the configuration? smiling 服务器环境搭建 0 2006-05-26 10:55 PM


所有时间均为北京时间. 现在的时间是 07:58 AM, Free Patent & Patent Ideas


Powered by vBulletin 3.5.2 Chinese Exhibition Happy New Year
©2000 - 2008,Jelsoft Enterprises Ltd  Desiccant Molecular Sieve Weight Loss Bentonite Trade Manager