2013-05-03 103 views
1

我只想知道是否存在與apache中所有環境變量的鏈接,以及它們在打印出來時的樣子。查找所有apache環境變量的名稱和視圖

原因是我想爲.htacess mod_rewrite寫一些正則表達式,但我不知道這些變量正在打印什麼。當我不確定打印什麼時,很難編寫正則表達式,我一直在弄錯他們。 是否有我失蹤的地方?

相信我使用谷歌搜索比發佈問題和等待響應要容易得多,而且人們不太清楚你被問到了什麼。

我似乎無法找到谷歌的來源。

比如%{} THE_REQUEST GET的index.php HTTP/1.1

我有真正的問題是我有這樣的.htaccess文件

# Do not remove this line, otherwise mod_rewrite rules will stop working 

RewriteBase/

Options +Multiviews 

AddHandler application/x-httpd-php .css 

AddHandler application/x-httpd-php .js 

Options +FollowSymLinks 
RewriteEngine On 


#NC not case sensitive 
#L last rule don't process futher 
#R 301 changes the url to what you want 

RewriteCond %{HTTP_HOST} !^example\.host56\.com 
RewriteRule ^(.*)$ http://example.host56.com/$1 [R=302,L] 

RewriteRule ^demo(.*)$ finished$1 [NC] 

RewriteCond %{REQUEST_URI}/
RewriteRule ^(.*)$ home/$1 

我不斷收到重定向到 錯誤頁面我試圖去

example.host56.com/home/ 

但它不斷導致我的錯誤。 home文件夾有一個index.php文件,它裏面還有

回答

1

這裏有一個mod_rewrite的變量小抄:http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html

的位置規則:

RewriteCond %{REQUEST_URI}/
RewriteRule ^(.*)$ home/$1 

是循環。原因是因爲%{REQUEST_URI}變量始終始於/,並且您沒有使用「^」或「$」來表示匹配邊界,因此該條件始終爲真。因爲它總是如此,規則將永遠得到答覆。由於重寫引擎不斷循環,直到URI停止更改(或者直到您達到內部遞歸限制,導致500錯誤),該模式始終匹配。嘗試將其更改爲:

RewriteCond %{REQUEST_URI} !^/home/ 
RewriteRule ^(.*)$ home/$1 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ home/$1 
相關問題