【问题标题】:finding the names and view of all apache environment variables查找所有 apache 环境变量的名称和视图
【发布时间】:2013-05-03 00:39:50
【问题描述】:

我只想知道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/

但它总是让我犯错误。主文件夹里面也有一个 index.php 文件

【问题讨论】:

    标签: php apache .htaccess environment-variables


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2020-08-18
      • 2011-02-25
      • 2016-10-02
      • 1970-01-01
      • 1970-01-01
      • 2015-05-08
      • 2013-05-28
      • 2012-06-25
      • 2010-09-23
      相关资源
      最近更新 更多