2012-10-02 22 views
1

我有一個只有wordpress(讓我們稱之爲博客)應用程序的網站。我現在需要添加另一個Web應用程序(讓我們稱之爲投資組合)到相同的域,並將博客移動到site.com/blog。用戶將能夠選擇在啓動頁面上訪問哪一個。所以基本上我將具有以下結構:將請求重定向到所有網址,但使用.htaccess登錄

site.com -> splash page 
site.com/blog 
site.com/portfolio 

的事情是,我不想打破整個網絡的現有鏈接到博客文章,並希望301重定向,未對/組合所有請求到博客應用程序,例如:

site.com/about_me redirects to site.com/wordpress/about_me but 
site.com/portfolio/index doesn't get redirected. 

我想這是在.htaccess文件內完成的,但是在大量閱讀後無法使其工作。

回答

1

使用RewriteCond匹配portfolio和不匹配的請求採取行動:

RewriteEngine On 
# if it isn't a real existing file (like img or css) 
# Remove these two lines if your images and CSS break on the wordpress site. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Rewrite (redirect 301) requests not already to portfolio or wordpress to /wordpress 
RewriteCond %{REQUEST_URI} !^/(portfolio|wordpress) 
RewriteRule ^(.*) wordpress/$1 [L,R=301] 
+0

非常感謝,就像一個魅力 – georgi

相關問題