mod_rewrite-将旧参数名称更改为新名称 [英] mod_rewrite - old parameter name to new name

查看:71
本文介绍了mod_rewrite-将旧参数名称更改为新名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我需要做一些重定向才能在mod_rewrite中工作.

Hi all I need a bit of getting a redirect working in mod_rewrite.

我需要重定向以下内容

http://mysite.com/dictionary/find?word=test

http://mysite.com/dictionary/find?w=test

我确定解决方案足够简单,但是我对mod_rewrite和正则表达式的了解非常有限,而且我还无法解决.到目前为止,这是我一直没有尝试过的尝试.

I'm sure the solution is trivial enough but my knowledge of mod_rewrite and regular expressions is quite limited and I haven't been able to work out. This is what I have attempted so far to no avail.

RewriteCond %{QUERY_STRING} word= [NC]
RewriteRule ^/(.*)word=(\w+)/$ /w=$1 [L]

任何帮助将不胜感激.谢谢.

Any help would be much appreciated. Thanks.

推荐答案

这对您来说应该足够了……

This should be sufficient for you...

RewriteRule(?|&)word =(\ w +)$ 1w = $ 2

RewriteRule (?|&)word=(\w+) $1w=$2

即使与其他参数结合使用,它也将取代它.您尝试仅处理查询字符串的尝试很有趣,我从未使用过,也无法回答.

this will replace it even if combined with other parameters.Your attempt to only process the querystring is interesting, I have never used that and cannot answer to if it's possible.

作为旁注,打开:

RewriteLog"/var/log/apache2/rewrite.log"
RewriteLogLevel 2

RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 2

获得更多有用的反馈.

这篇关于mod_rewrite-将旧参数名称更改为新名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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