0
我將我的PHP(LAMP)應用程序遷移到Google App Engine託管。我已經完成了大部分的工作,但現在我堅持將.htaccess規則轉換爲app.yaml版本。Google App Engine重定向/重寫
# Redirect all requests for any domain not being "www.domain.com"
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301,NC]
# Redirect all requests for the mobile version to the mobile subdomain
RewriteCond %{REQUEST_URI} ^/([a-z][a-z])/mobile(/)?(.*)
RewriteRule ^([a-z][a-z])/mobile(/)?(.*) https://m.domain.com/$1/$3 [R=301,L]
# If the URL contains ".php", then the request should be handled by that particular script
RewriteCond %{THE_REQUEST} (.*\.php) [NC]
RewriteRule ^([a-z][a-z])/(.*) /$2 [L]
# Most of the other requests should be handled by redirector.php
RewriteCond %{THE_REQUEST} !(/([a-z][a-z])/controls/.*)
RewriteCond %{THE_REQUEST} !(/api/.*)
RewriteCond %{THE_REQUEST} !(/admin/.*)
RewriteCond %{HTTP_HOST} !^m\.domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule^redirector.php [L]
我的問題是三種:
- 如何,如果將用戶重定向到www.domain.com訪問通過domain.com
- 如何改寫爲2個字符的語言代碼恰好位於域名後面,並將其作爲GET參數傳遞給PHP(與其他參數一起添加)
- 如何檢查請求的文件/目錄是否存在,如果不存在,請加載redirector.php文件這將處理漂亮/虛擬鏈接本身。
我在https://cloud.google.com/appengine/docs/php/config/appconfig檢查文檔和https://cloud.google.com/appengine/docs/python/config/appconfig
是的,我確實已經閱讀並檢查了這一點,但所有這一切實際上是在上面的示例中將所有內容重定向到redirector.php,然後在php中使用複雜的preg替換和文件檢查來放置巨大的case/switch條件而不是使用原始請求,而不是使用腳本。 – Lincoln 2014-11-24 08:15:30