gpt4 book ai didi

.htaccess - 简单的 htaccess 重定向 - 子域到文件夹

转载 作者:行者123 更新时间:2023-12-04 06:57:54 25 4
gpt4 key购买 nike

我正在尝试重定向 http://[random-string].domain.com/http://domain.com/folder/[random-string]/

我目前有这个:

RewriteCond %{HTTP_HOST} ^.*\.domain\.com
RewriteRule ^.*$ http://domain.com/folder/$1/ [R=301,L]

它当前指向 http://domain.com/folder// . (缺少 1 美元)我该如何解决这个问题?

最佳答案

在您的情况下,您需要使用括号来获取匹配的值:

RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/folder/%1/$1 [R=301,L]

假设您还想重定向 http://[random-string].domain.com/somethinghttp://domain.com/folder/[random-string]/something

关于.htaccess - 简单的 htaccess 重定向 - 子域到文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2322586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com