将域重写为静态html页面

时间:2013-12-17 13:58:35

标签: apache .htaccess rewrite

我有3个域名的3次登陆,

所以我想:

.com打开index.html
.se打开index_sw.html
.es打开index_es.html

这就是我的尝试:

RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC] 
RewriteRule ^(.*)$ index.html [NC,QSA] 
RewriteCond %{HTTP_HOST} ^www\.domain\.se [NC] 
RewriteRule ^(.*)$ index_sw.html [NC,QSA] 
RewriteCond %{HTTP_HOST} ^www\.domain\.es [NC] 
RewriteRule ^(.*)$ index_es.html [NC,QSA] 

但它们都在解析index.html

知道我错过了什么吗?

- 编辑 -

尝试:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC] 
RewriteRule ^(.*)$ index.html [NC,QSA] 
RewriteCond %{HTTP_HOST} ^www\.domain\.se [NC] 
RewriteRule ^(.*)$ index_sw.html [NC,QSA] 
RewriteCond %{HTTP_HOST} ^www\.domain\.es [NC] 
RewriteRule ^(.*)$ index_es.html [NC,QSA] 

但仍然看到index.html

- 编辑 -

Also tried with:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC] 
RewriteRule ^ /index.html [L] 

RewriteCond %{HTTP_HOST} ^www\.domain\.se$ [NC] 
RewriteRule ^ /index_sw.html [L] 


RewriteCond %{HTTP_HOST} ^www\.domain\.es$ [NC] 
RewriteRule ^ /index_es.html [L] 

同样的结果......

1 个答案:

答案 0 :(得分:1)

DOCUMENT_ROOT/.htaccess文件中试用此代码:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC] 
RewriteRule ^ /index.html [L] 

RewriteCond %{HTTP_HOST} ^www\.domain\.se$ [NC] 
RewriteRule ^ /index_sw.html [L] 

RewriteCond %{HTTP_HOST} ^www\.domain\.es$ [NC] 
RewriteRule ^ /index_es.html [L]