如何在 .htaccess 文件中进行通配符重定向?
我尝试使用以下内容,但 *
由于某种原因不起作用。
重定向 301/threads/*.343/http://myotherdomain.com/threads/*.343/
我无法使用 mod_rewrite,因为我需要执行 7000 个重定向,显然,当我尝试其中大约一半时,我的服务器抛出了 500 个配置错误错误。
因此,编写上述 7000 行代码似乎在某种程度上不那么密集。
无论如何,请让我知道如何在此类代码中表达通配符。
最佳答案
使用 mod_alias,您可以使用 RedirectMatch
相反:
RedirectMatch permanent ^/threads/[^/]+\.343/$ http://myotherdomain.com$0
这会匹配所有与 /threads/*.343/
匹配的 URL,*
是除 /
之外的任何字符。
关于apache - 使用通配符通过 .htaccess 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15579531/