2013-08-20 90 views
0

我目前正在鞏固職位上,我們最近收購了一家網站,有多種安裝WordPress的管理內容,一個在public_html文件夾,另一個在子目錄中,像這樣:的.htaccess子目錄重寫異常

1. http://domain.com/ 
2. http://domain.com/another-install/ 

我們將所有的內容從/another-install/到主設置,並使用301重定向從所有舊鏈接,像這樣刪除/another-install/:重定向,像這樣

RedirectMatch 301 ^/another-install/(.*) http://domain.com/$1 

所有文章在所得:

http://domain.com/another-install/article-name/ 
TO 
http://domain.com/article-name/ 

問題是,我們想保留/another-install/作爲一個頁面可見。使用當前的重定向,http://domain.com/another-install/轉到http://domain.com/。有什麼方法可以添加異常,或者重寫當前的規則以保持/another-install/可見?

回答

0

將您的正則表達式從(.*)(匹配0個或更多任何字符)更改爲(.+)(匹配1個或多個任意字符)。這意味着必須有一些東西在/another-install/之後纔能有重定向。

+0

試了一下,並清除了要檢查的緩存。它現在將轉到「http:// domain.com/index.wml」而不是重定向到主頁,但它不顯示一個頁面(我在主安裝中創建了一個顯示)。有任何想法嗎? – thatsamore

0

您需要RewriteRule來指定排除。將此添加到您的.htaccess文件中

RewriteCond %{REQUEST_URI} !^/old-install/(index\.wml)?$ [NC] 
RewriteRule ^old-install/(.+)$ http://domain.com/$1 [R=301,NC,L]