首页 文章

完整URL的Apache RewriteMap语法

提问于
浏览
0

我有一个重写 Map ,大约有5000个条目,如下所示:

http://www.example.com/some-random-url http://www.example.net/some-random-url

对于每个条目,源域(例如上面的example.com)是相同的,但是上面的目标域example.net是不同的域 . 路径模式也随着每个URL而变化(我希望我可以发布超过2个链接!)

到目前为止我所拥有的是:

RewriteEngine On RewriteMap examplemap“txt:/etc/httpd/conf/redirect.txt”RewriteCond $ {examplemap:$ 1}!=“”RewriteRule ^ /( . *)$ {examplemap:$ 1} [redirect = permanent,last]

我似乎无法获得RewriteCond和RewriteRule指令的正确语法,并感谢任何帮助,谢谢 .

1 回答

  • 0

    如果我理解正确,您希望重写映射的键是当前URL,然后找到匹配的重定向 .

    然后你可以使用:

    RewriteRule .* ${examplemap:http://%{HTTP_HOST}%{REQUEST_URI}}

相关问题