【问题标题】:Rewrite with relative path用相对路径重写
【发布时间】:2013-05-21 09:48:00
【问题描述】:

我对我本地机器上的 reqrite 规则要发疯了...

我什至启用了重写日志,这是我从应该重写的 url 上的单个页面加载中得到的:

ip - - [21/May/2013:08:13:18 +0200] [scxx/sid#7f6580ce32b8][rid#7f65810069e0/initial] (2) init rewrite engine with requested uri /catdev/sc/eprocure/ajax/ArticleSearch/SearchEngine/GetInitialData
ip - - [21/May/2013:08:13:18 +0200] [scxx/sid#7f6580ce32b8][rid#7f65810069e0/initial] (3) applying pattern '^/catdev/sc/eprocure/ajax/(.+)/(\w+)/(\w+?)$' to uri '/catdev/sc/eprocure/ajax/ArticleSearch/SearchEng$
ip - - [21/May/2013:08:13:18 +0200] [scxx/sid#7f6580ce32b8][rid#7f65810069e0/initial] (2) rewrite '/catdev/sc/eprocure/ajax/ArticleSearch/SearchEngine/GetInitialData' -> '/catdev/sc/eprocure/ajax/handler.php?pa$
ip - - [21/May/2013:08:13:18 +0200] [scxx/sid#7f6580ce32b8][rid#7f65810069e0/initial] (3) split uri=/catdev/sc/eprocure/ajax/handler.php?path=ArticleSearch&class=SearchEngine&method=GetInitialData -> uri=/catde$
ip - - [21/May/2013:08:13:18 +0200] [scxx/sid#7f6580ce32b8][rid#7f65810069e0/initial] (2) local path result: /catdev/sc/eprocure/ajax/handler.php
ip - - [21/May/2013:08:13:18 +0200] [scxx/sid#7f6580ce32b8][rid#7f65810069e0/initial] (1) go-ahead with /catdev/sc/eprocure/ajax/handler.php [OK]

正确找到了路径,但它仍然没有加载它应该加载的页面。我不知道为什么!

错误日志显示了这一点。

[Tue May 21 08:13:18 2013] [error] [client xxx.xxx.xxx.xx] File does not exist: /catdev/sc/eprocure

现在我的 apache 配置中有这些重写规则:

<VirtualHost *:80>
        ServerAdmin webmaster@xxx.at
        ServerName xxx
        DocumentRoot /data1/www/somewherefarbeyond/ssl-htdocs

        <Directory /data1/www/somewherefarbeyond/ssl-htdocs/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /data1/www/somewherefarbeyond/logs/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /data1/www/somewherefarbeyond/logs/access.log combined


        RewriteEngine On
         RewriteRule ^/catdev/sc/eprocure/ajax/(.+)/(\w+)/(\w+?)$      /catdev/sc/eprocure/ajax/handler.php?path=$1&class=$2&method=$3 [L]
        RewriteLog /data1/www/somewherefarbeyond/logs/accessREWRITE.log
        RewriteLogLevel 9

</VirtualHost>

somone 能给这件事带来一些启示吗?

我正在尝试的网址是 xxx/catdev/sc/eprocure/ajax/ArticleSearch/SearchEngine/GetInitialData

注意 xxx 是来自我的开发服务器的手动 owerwriten 域,并且 ips 被隐藏了。

【问题讨论】:

  • 奇怪的是,当我将重定向网址添加为绝对网址时,它会被重定向。但在外部,而不是内部,可悲的是 Q_Q...有人知道为什么吗?

标签: apache url mod-rewrite url-rewriting rewrite


【解决方案1】:

该死的。

Iw 是一个 debian“功能”

我在一个 debian 发行版上工作,由于某些奇怪的原因,当您在基本配置中进行重写时,您必须指定整个 DIRECTORY 路径而不是相对路径。

只需将重写的 url 设为目录位置而不是 url!

例子是:

您的 www 文件夹位于

/motherofGod/wtf/www

您的 www 根在补丁中设置为 /motherofGod/wtf/www

您的域名是 lols.com

所以文件lols.com/lol/wtf

需要转到/motherofGod/wtf/www/some/crap/handler.php

你必须指定整个路径,而不仅仅是 www 目录的相对路径~_~

【讨论】:

    猜你喜欢
    • 2010-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-04
    • 1970-01-01
    • 2013-07-17
    • 2016-02-10
    相关资源
    最近更新 更多