在Apache中,如何重写" .NAME"到" ../ AJAX / name.php" [英] in apache, how to rewrite ".name" to "../ajax/name.php"

查看:125
本文介绍了在Apache中,如何重写" .NAME"到" ../ AJAX / name.php"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

../ AJAX 目录及所有 xmlRequest 的URL开始以一个点,所有的Ajax如

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

将被改写为

  ../ call.php?ARG = VAL

用处理程序在PHP做的工作,但更愿意简单地使用Apache

MOD rewrite.load 启用


解决方案

你是不是你想要改写为别的什么文件路径相当一致。我会假设你有一个文件,call.php,位于Ajax的文件夹(domain.com/ajax/call.php),并且希望这个与domain.com/.call

假设你已经激活了重写引擎,并且知道往哪里放重写规则,你想应该是这样的什么合适的重写规则:

 重写规则^ \\([AA-zZ0-9] +)(。*)$ AJAX / $ $ 1.PHP 2

这与重写一个。pfixed什么$ P $对Ajax的文件夹,并用的.php后缀的。此外,论据都完好无损。

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

解决方案

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.

这篇关于在Apache中,如何重写" .NAME"到" ../ AJAX / name.php"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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