htaccess为子域名

时间:2011-06-24 11:18:49

标签: .htaccess mod-rewrite

需要帮助.htaccess 我的本地主机上有这个.htaccess的网站

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ website/index.php/$1 [L]

现在我想将网站移至subdomain.domain.com

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://subdomain.domain.com/index.php/$1 [L]

我查了网址,但这不起作用,可能是因为这是我不知道的子域名

托管详情:

#   Subdomain Name              Path [?]    
1   subdomain.domain.com    /home/www/subdomain.domain.com

我的网址就像这样

http://website/index.php/contact

使用此htaccess我可以使用

http://website/contact

当我将网站移动到子域名时,我可以使用http://subdomain.website/index.php/contact,但是当我尝试http://subdomain.website/contact给我错误时

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

1 个答案:

答案 0 :(得分:5)

试试这个,它应该适用于所有域localhost和服务器。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

确保服务器上的“rewrite_engine = on”。