【问题标题】:Apache Rewrite and Alias combinedApache Rewrite 和 Alias 相结合
【发布时间】:2010-05-12 18:27:09
【问题描述】:

我们遇到了一个问题,我们有一个现有的别名,我们想添加一个重写规则来捕获不区分大小写的拼写的所有变体,即:

URL:  http://www.example.com/example

Alias  /example  "/var/www/html/web/example"

我们需要一个重写规则来捕捉:

/ExamPle

/exampLE

/eXAmple

等等……

我们似乎无法让 rewrite 和 Alias 一起工作。

【问题讨论】:

    标签: apache mod-rewrite mod-alias


    【解决方案1】:

    在您的主要配置中:

    RewriteRule ^/example(?:$|/)(.*) /example/$1 [NC,PT,R]
    

    神奇之处在于 NC(无大小写)修饰符。如果你不想要前锋,你可以省略 R 修饰符。 PT (pass-through) 修饰符应该使它与Alias 配合得很好。

    【讨论】:

    • 非常感谢您的回复。不幸的是,这会导致以下错误:Bad Request: Invalid URI in request GET /example HTTP/1.1 I found how apache internal processes Aliases & Rewrites: Internal Processing: /xyz/oldstuff.html -> /abc/def/oldstuff. html (每服务器别名) /abc/def/oldstuff.html -> /abc/def/newstuff.html (每目录 RewriteRule) /abc/def/newstuff.html -> /xyz/newstuff.html (每dir RewriteBase) /xyz/newstuff.html -> /abc/def/newstuff.html (per-server Alias) 任何帮助将不胜感激谢谢!
    • 请写出你当前相关的配置指令是什么。
    猜你喜欢
    • 2019-06-26
    • 2011-03-20
    • 1970-01-01
    • 2022-01-10
    • 2010-09-24
    • 2017-10-13
    • 2010-12-30
    • 1970-01-01
    • 2014-03-16
    相关资源
    最近更新 更多