在apache中,如何重写“.name”到“../ajax/name.php”

发布于 2024-12-23 15:37:03 字数 291 浏览 0 评论 0原文

将所有 ajax 放在 ../ajax 目录中,并且所有以点开头的 xmlRequest url,例如,

http://company.com/.call?arg=val

将被重写为

../call.php?arg=val

使用 php 中的处理程序来完成这项工作,但会更简单地使用 apache

mod rewrite.load 启用

have all ajax in ../ajax directory and all xmlRequest urls starting with a dot, eg,

http://company.com/.call?arg=val

would be rewritten as

../call.php?arg=val

was using handler in php to do the job, but would much rather simply use apache

mod rewrite.load enabled

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的往事 2024-12-30 15:37:03

您与要重写为其他内容的文件路径不太一致。我假设您有一个文件 call.php,位于“ajax”文件夹 (domain.com/ajax/call.php) 中,并且您希望使用 domain.com/.call 调用该文件

假设您有激活重写引擎,并知道在哪里放置重写规则,您想要的适当的重写规则如下所示:

RewriteRule ^\.([aA-zZ0-9]+)(.*)$ ajax/$1.php$2

这会重写以“.”为前缀的任何内容。到 ajax-folder 并添加后缀“.php”。此外,论据完好无损。

You are not quite consistent with what file path you want rewritten to something else. I am going to assume that you have a file, call.php, located in the "ajax" folder (domain.com/ajax/call.php) and you want this to be called with domain.com/.call

Assuming you have activated the rewrite engine, and know where to put rewrite rules, the appropriate rewrite rule for what you want would look like this:

RewriteRule ^\.([aA-zZ0-9]+)(.*)$ ajax/$1.php$2

This rewrites anything prefixed with a "." to the ajax-folder and suffixes it with ".php". Additionally, arguments are intact.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文