如何调用不同的索引文件的主要领域和子domins?索引、不同、领域、文件

由网友(读不懂旳心)分享简介:我有在www.mysite.com的名称的部位。当网址是www.mysite.com,我想打电话给index1.php文件(这是我的主域名)。 i have a site in the name of www.mysite.com. when the url is www.mysite.com, i want to...

我有在www.mysite.com的名称的部位。当网址是www.mysite.com,我想打电话给index1.php文件(这是我的主域名)。

i have a site in the name of www.mysite.com. when the url is www.mysite.com, i want to call index1.php file (this is my main domain).

如果该URL是像test1.mysite.com,test2.mysite.com子域名的话,我想打电话给index2.php文件。

If the url is from sub domains like test1.mysite.com, test2.mysite.com then i want to call index2.php file.

如何做htaccess的?任何帮助是极大的AP preciated ..

How to do it in htaccess? any help is greatly appreciated..

在此先感谢!

推荐答案

如果他们都在同一个文档根目录,把这样的事情在你的htaccess文件中的文档根目录:

If they are both in the same document root, put something like this in your htaccess file in the document root:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ [NC]
RewriteRule ^$ /index1.php [L]

RewriteCond %{HTTP_HOST} !^(www.)?mysite.com$ [NC]
RewriteRule ^$ /index2.php [L]

如果您有链接到需要重写目录索引,​​你可以做那些对案件逐案的基础,例如:

If you have links to directory indexes that need to be rewritten, you can do those on a case-by-case basis, for example:

RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ [NC]
RewriteRule ^(.*)/index.(php|html|htm)$ /$1/index1.php [L]

RewriteCond %{HTTP_HOST} !^(www.)?mysite.com$ [NC]
RewriteRule ^(.*)/index.(php|html|htm)$ /$1/index2.php [L]
阅读全文

相关推荐

最新文章