2010-11-23 81 views
0

我想設置子如下:的.htaccess子域

http://subdomain.domain.com應該加載什麼是真正http://subdomain.domain.com/index.php/contest/

http://subdomain.domain.com/stepone應該加載什麼是真正http://subdomain.domain.com/index.php/contest/stepone

http://subdomain.domain.com/images/example.jpg應加載http://subdomain.domain.com/images/example.jpg爲正常。

我已經有了這一切設置和工作在主要域的子目錄之前,但現在我試圖做一個子域它停止工作。

這裏是我的.htaccess:

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|stylesheets|javascript|email|robots\.txt|test\.php|terms\.html) 
RewriteRule ^(.*)$ /index\.php/contest/$1 [L] 

請幫幫我!

+0

你得到的錯誤是什麼? – 2010-11-23 03:33:49

回答

1

重寫規則是否工作?即你有AllowOverride All什麼的虛擬主機,按:

而且,看看這個評論的濃湯在這太問題:

+0

是的,mod_rewrite已打開。它也適用,如果我使用以下內容:RewriteRule ^(。*)$ http://subdomain.domain.com/index\.php/contest/$1 [L]但它然後就像一個重定向,我最終與地址欄中的長URL。 – 2010-11-23 03:45:52

1

Drupal .htaccess文件是映射/?q =查詢到/ query的一個很好的例子,但不是r edirecting提供明確的文件/目錄匹配的東西。以下是來自Drupal的.htaccess的相關代碼片段?q =更改爲index.php/contest /。

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

如果您需要限制的領域,使其無法正常重定向只是從一個域,插入前RewriteRule這樣的:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC] 
0

我想我已經找到了使用應答:

RewriteRule ^(.*)$ subdomain.domain.com/index\.php/contest/$1 [L, P] 

是否有任何理由我不應該使用這樣的強制代理? (它會減慢速度嗎?)

感謝您的答案。