2016-01-22 46 views
0

我有一個問題,我不能重寫只有根文件。例如example.com到example.com/landing-page/mypage.html,但保留所有其他地址,如example.com/something/完整。重寫只有root沒有重定向不起作用

目前用於測試目的,我已成功地重定向/測試/我的.htaccess如下:

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_URI} ^/test/.*$ 
RewriteRule . /wp-content/themes/mytheme/landing_page.html [L] 

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

但現在,如果我嘗試重定向只有root和替換的RewriteCond與

RewriteCond %{REQUEST_URI} ^/$ 

它不起作用,它加載我的WordPress的網站。

UPDATE:
我只用簡單的規則RewriteRule ^/?$ /mypage/landing-page.html [L]也保持WordPress的線路另一臺服務器上進行測試,並在那裏工作,但同樣的思路並不在此服務器上運行。所以現在問題出現了什麼服務器設置可能會阻止這個簡單的規則。

回答

0

看起來你忘了在第二個例子中打開RewriteEngine。

RewriteEngine On 
RewriteRule ^$ /landing-page/mypage.html [NC,L] 
+0

不,我擁有它。這僅僅是作爲例子顯示只有那一行,我沒有開始的領域。 – igrynsh