doulei1965 2010-08-14 00:17
浏览 14
已采纳

在mod-rewrite中传递和URL作为参数

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>

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:');

Any Ideas?

Thanks in advance /Ale

  • 写回答

1条回答 默认 最新

  • duanchanguo7603 2010-08-14 13:39
    关注

    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]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据