我目前正在開發一個項目,其中我的Apache documentroot與我的index.php所在的公共目錄不同。奇怪的是,由於這個設置,我的$ _GET超全球似乎被清空了。
目錄結構:
- /DocumentRoot的
- /Documentroot/.htaccess
- /public/.htaccess
- /public/index.php
處理第一個.htaccess後出現問題。
#First .htaccess in Apache documentroot:
RewriteEngine On
RewriteRule (.+) public/$1 [NC,L]
# Second .htaccess in /documentroot/public:
SetEnv APPLICATION_ENV testing
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
一些觀察:
- 當刪除主的.htaccess,並把額外的index.php在documentoot,我的$ _ GET變量顯示細膩
- 當傾倒$ _GET /public/index.php文件,它是空的
- 當調用index.php像/?foo = bar時,$ _GET爲空
- 當調用index.php像/ ind ex.php?富=酒吧$ _GET填充
什麼引起$ _GET變量被掏空?任何幫助表示讚賞。
編輯:事情只是得到了一大堆陌生人:
當我離開這兩個.htaccess文件完好,並放置一個index.php文件(無論(或任何指數*爲此事)。什麼內容),/ public目錄中的index.php文件被解析,$ _GET變量被正確填充。
可能不是問題,但是您確定在文檔根目錄中沒有「index.htm」或其他類似文件嗎?嘗試將'DirectoryIndex index.php'添加到'.htaccess'中。 – 2010-11-03 16:25:55
感謝您的評論,但我確定這不是問題。 – 2010-11-03 17:18:46