今天把3個網站,其中一個CodeIgniter建的網站,和兩個wordpres網站,全部搬到一個網域名稱下面來了,又是頗費一番周折,最近總是喜歡折騰!
首先,這三個網站現在的網域名稱是:
http://你的網域名稱 (wordpress)
http://你的網域名稱/tanteng/ (wordpress)
http://你的網域名稱/hongzhiban/ (CodeIgniter)
如果不是在BAE3.0的環境下,把其他網站直接搬過來,資料庫表放到一起共用資料庫,然後改下資料庫連接配置,基本上就OK了。
但是在BAE3.0環境下,檔案夾,路由,檔案的路徑怎麼區分呢?你不僅要配置路由規則,還要讓BAE知道哪個是檔案夾。
現在完整的app.conf檔案:
handlers:
- expire : .jpg modify 10 years
- expire : .swf modify 10 years
- expire : .png modify 10 years
- expire : .gif modify 10 years
- expire : .JPG modify 10 years
- expire : .ico modify 10 years
- url : (.*).css$
script : $1.css
- url : (.*).js$
script : $1.js
- url : (.*).jpg$
script : $1.jpg
- url : (.*).gif$
script : $1.gif
- url : (.*).png$
script : $1.png
- url : (.*).jpeg$
script : $1.jpeg
- url : (.*).php$
script : $1.php
- url : (.*).html$
script : $1.html
- url : (.*).xml$
script : $1.xml
- url : (.*).txt$
script : $1.txt
- url : (.*).ico$
script : $1.ico
- url : /hongzhiban(.*)
script : /hongzhiban/index.php
- url : /tanteng/wp-admin/
script : /tanteng/wp-admin/index.php
- url : /tanteng/wp-includes/(.*)
script : /tanteng/wp-includes/$1
- url : /tanteng/wp-content/(.*)
script : /tanteng/wp-content/$1
- url : /tanteng(.*)
script : /tanteng/index.php
- url : /wp-admin/
script : /wp-admin/index.php
- url : (.*)
script : /index.php
後來又發現一個問題:
http://你的網域名稱/author/tanteng/作者頁面打不開,但是http://你的網域名稱/tanteng/article/author/tanteng9/這個作者頁面可以開啟。
仔細看看app.conf檔案,原來http://你的網域名稱/author/tanteng/作者名稱和後面http://你的網域名稱/tanteng/這個網站名稱一樣,因此前面這個網址被誤以為是後面網站下面的路由,因此轉寄到後面網站的index.php去了。
然後進行修改,經過幾番測試,要這樣寫:
- url : /article(.*)
script : /tanteng/index.php
- url : /author(.*)
script : /index.php
而且要注意順序,前面的會覆蓋後面,所以你的網域名稱完整的正確的app.conf配置如下:
handlers:
- expire : .jpg modify 10 years
- expire : .swf modify 10 years
- expire : .png modify 10 years
- expire : .gif modify 10 years
- expire : .JPG modify 10 years
- expire : .ico modify 10 years
- url : (.*).css$
script : $1.css
- url : (.*).js$
script : $1.js
- url : (.*).jpg$
script : $1.jpg
- url : (.*).gif$
script : $1.gif
- url : (.*).png$
script : $1.png
- url : (.*).jpeg$
script : $1.jpeg
- url : (.*).php$
script : $1.php
- url : (.*).html$
script : $1.html
- url : (.*).xml$
script : $1.xml
- url : (.*).txt$
script : $1.txt
- url : (.*).ico$
script : $1.ico
- url : /hongzhiban(.*)
script : /hongzhiban/index.php
- url : /weibo(.*)
script : /weibo/index.html
- url : /tanteng/wp-admin/
script : /tanteng/wp-admin/index.php
- url : /tanteng/wp-includes/(.*)
script : /tanteng/wp-includes/$1
- url : /tanteng/wp-content/(.*)
script : /tanteng/wp-content/$1
- url : /article(.*)
script : /tanteng/index.php
- url : /author(.*)
script : /index.php
- url : /tanteng(.*)
script : /tanteng/index.php
- url : /wp-admin/
script : /wp-admin/index.php
- url : (.*)
script : /index.php