如何调用index.php作为默认值,但仅限于特定域?

时间:2013-10-14 19:59:02

标签: .htaccess

我在同一台服务器上托管了几个网站, 但是我只有一个htaccess文件可以管理所有这些文件。 那么我怎样才能将index.php作为默认值而不是index.html只针对其中一个网站?

谢谢!

# -FrontPage-


IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*


<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName site1.com
AuthUserFile /home/myuser/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/myuser/public_html/_vti_pvt/service.grp
AddHandler server-parsed .shtml
AddHandler server-parsed .html

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site1\.com
RewriteRule ^(.*)$ http://www.site1.com/$1 [R=permanent,L]
RewriteCond %{HTTP_HOST} ^(www\.)?site2\.com$ [NC]
RewriteRule ^(index\.html)?$ /index.php [L,NC]`

1 个答案:

答案 0 :(得分:1)

对于任何特定网站www.site.com,您的.htaccess都有此规则:

RewriteCond %{HTTP_HOST} ^(www\.)?site\.com$ [NC]
RewriteRule ^(index\.html)?$ /index.php [L,NC]

建议.htaccess

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site1\.com
RewriteRule ^(.*)$ http://www.site1.com/$1 [R=permanent,L]

RewriteCond %{HTTP_HOST} ^(www\.)?site2\.com$ [NC]
RewriteRule ^(index\.html)?$ /index.php [L,NC]

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName site1.com
AuthUserFile /home/myuser/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/myuser/public_html/_vti_pvt/service.grp
AddHandler server-parsed .shtml
AddHandler server-parsed .html