有什么不对的mod_rewrite的说法? [英] What's wrong with this mod_rewrite statement?

查看:139
本文介绍了有什么不对的mod_rewrite的说法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要复制 mod_alias中的功能,这是因为我在共享主机我不能直接使用,和Alias​​语句不会在.htaccess工作。

I need to replicate the functionality of mod_alias which I can't use directly because I'm on shared hosting, and Alias statements don't work in .htaccess.

我想实现本质上是

Alias /manual /www/customer/some_other_dir/manual

我想mod_rewrite的:

I am trying mod_rewrite:

RewriteRule ^/manual/(.*) /www/customer/some_other_dir/manual/%1?%{QUERY_STRING} [L]

这不会匹配到 www.example.com/manual 任何来电。

this will never match any calls to www.example.com/manual.

为什么不呢?我在做什么错了?

Why not? What am I doing wrong?

推荐答案

尝试:

RewriteRule ^/manual(/(.*))?$ /www/customer/some_other_dir/$2 [L]

表示可选,除了克林封闭的 / 字符>。来确保 /手动 /手动/ /手动/ A / b / C 虽然我收集斜线通常是由阿帕奇pre-重写反正引擎补充说。

The ? means optional for the / character in addition to the kleene closure on the . to ensure /manual, /manual/ and /manual/a/b/c although I gather a slash is usually added by apache pre-rewrite engine anyway.

在我的箱子一个快速测试表明此规则也通过查询字符串:

A quick test on my box shows this rule also passes the query string:

/manual/a/b?c=d -> /www/customer/some_other_dir/manual/$2

这篇关于有什么不对的mod_rewrite的说法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆