2013-05-03 90 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