我有 2 个域指向我网站的根目录:
http://site1.com
http://site2.com
both point to http://dXXXXXXX.domain.com/
我将每个站点都设置为在子目录(同名)中查找其文件,所以
http://site1.com files are located in http://dXXXXXXX.domain.com/site1/
http://site2.com files are located in http://dXXXXXXX.domain.com/site2/
我想为 site1(可能还有 site2)创建一个特殊的子域,它实际上指向主目录中的一个文件夹(两个域可以共享的论坛)。我想用子域网址屏蔽真实网址,如下所示:
http://subdomain.site1.com masks http://dXXXXXXX.domain.com/shared_folder/ (not redirected)
我的 .htaccess 文件(在最顶层目录中)如下所示:
Options +FollowSymLinks
RewriteEngine On
# Rewrite "www.domain.com -> domain.com"
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>
# redirect site1.com to /site1 [folder]
# redirect site2.com to /site2 [folder]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^([^0-9]+)$ [NC]
RewriteRule ^(.*)$ /%1/$1 [QSA,L]
#i think this should work but it doesn't
#RewriteCond %{HTTP_HOST} ^subdomain\.site1\.com$ [NC]
#RewriteRule ^$ shared_folder [P]
另外,如果可能的话,我想将每个域的绝对路径重定向到我的首选路径,如下所示:
http://dXXXXXXX.domain.com/site1/ redirects to http://site1.com
http://dXXXXXXX.domain.com/site2/ redirects to http://site2.com
不确定是否有人会找到这些链接,但我希望通过对同一内容没有多个访问点来保持一切清洁(故意共享的 css 或论坛软件除外)
提前感谢您对我的任何帮助或见解