2012-08-10 104 views
0

我想重定向WordPress的默認登錄(wp-logiin.php)url登錄,但不知何故它不工作。我從來沒有這樣做過.htaccess重寫規則,所以不知道它是如何工作的。重定向規則不起作用

# BEGIN WordPress 
RewriteRule ^signin$ http://localhost/newsite/wp-login.php [NC,L,R] 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /newsite/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /newsite/index.php [L] 
</IfModule> 

# END WordPress 

大非常感謝

回答

1

嘗試閱讀手冊:) http://httpd.apache.org/docs/current/mod/mod_rewrite.html


首先,如果你想用「改寫」,條件必須是首先定義,然後是條件滿足時使用的規則。例如:

RewriteCond %{HTTP_USER_AGENT} ^facebookexternalhit [OR,NC] 
RewriteCond %{HTTP_USER_AGENT} ^Zeus [NC] 
RewriteRule ^.* /errors/404.html [F] 

RewriteRule ^signin$ http://localhost/newsite/wp-login.php [NC,L,R]<br> 

沒有定義RuleCondition使用重寫規則的,因此恕我直言,這條規則將不會被使用,從來沒有。


RewriteCond %{REQUEST_FILENAME} !-f<br> 
RewriteCond %{REQUEST_FILENAME} !-d<br> 
RewriteRule . /newsite/index.php [L]<br> 

如說手冊「Pattern是一個perl兼容的正則表達式」。,因此單個「。」作爲模式意味着一個單一的字符所以,如果請求文件名將是「test.txt」,它將用「/newsite/index.php」替代每個字母(8個字符= 8x重複)。
正確的版本是:RewriteRule ^。* $ /newsite/index.php [L]

+0

你在真正細節和解釋,但我是全新的,所以既不明白語法也沒有任何代碼:(所有人仍然混淆如何使其工作重定向登錄網址? – 2012-08-10 19:43:54

1

你重定向登錄到本地主機,所以,除非你使用同一臺機器,你的WordPress網站上運行的瀏覽器,你可能會得到一個連接錯誤。嘗試刪除HTTP://位從您的規則:

RewriteRule ^signin$ /newsite/wp-login.php [NC,L,R]