传递和URL作为mod-rewrite参数 [英] Passing and URL as parameter in mod-rewrite
问题描述
我想传递一个URL作为mod-rewrite的参数。我想有我的正则表达式的一个问题。这是我的.htaccess:
I'm trying to pass an URL as a parameter in mod-rewrite. I guess there is a problem in my Regex. This my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule **^go/((http:\/\/)+[A-Za-z0-9\-]+[\.A-Za-z])/?$** feedmini.php?url=$1 [L]
</IfModule>
我想通过貌似URL的 http://www.aaaa.com/aaa/?q=v 的,但是当我曾经尝试去实现它就走/ HTTP:// WWW .aaaa.com / AAA / q = v I得到一个404错误页面。我也试图与 ** ^去/([A-ZA-Z0-9 \\ - \\ /:] + [。\\ A-ZA-Z] +)?/ $ **
但后来我通过URL获取这样的:HTTP:/www.aaaa.com/aaa/(观察辛格运河'/'后的http:');
the URL I want to pass looks like http://www.aaaa.com/aaa/?q=v but when ever I try to reach it on go/http://www.aaaa.com/aaa/?q=v I get an 404 error page. I've also tried with **^go/([A-Za-z0-9\-\/:]+[\.A-Za-z]+)/?$**
but then the URL i pass gets like this: http:/www.aaaa.com/aaa/ (observe the singel '/' after 'http:');
任何想法?
在此先感谢
/ ALE
Thanks in advance /Ale
推荐答案
嗯,你的第一个问题(在你的第一个code座)是你的正则表达式模式不匹配的URL,因为它只会匹配开始的字符串以http://然后只含有alphanum或破折号,它用一个句号或字母结束。也许这只是一个错字,并应该有一个量词在那里,但即便如此,它会失败匹配非常大的比例或URL。
Well your first problem (in your first code block) is that your Regex pattern will not match a URL since it will only match a string that begins with http:// then contains nothing but alphanum or dashes, which ends with a single fullstop or letter. Perhaps this is simply a typo and there should be a quantifier in there, but even so it would fail to match a very large percentage or URLs.
这看起来可能有点陌生,但试试这个...
This may seem a little strange, but try this...
RewriteRule ^go/http:/(.*)/?$ feedmini.php?url=http://$1 [R=302,L]
这篇关于传递和URL作为mod-rewrite参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!