使用.htaccess重定向,并将任何附加的文本传输到新的重定向


Use .htaccess to redirect with any appended text transferred to new redirect

我有点卡住了。我在.htaccess 中有以下重定向

Redirect http://www.domain1.com http://www.domain2.com/subdomain=

尽管我希望,如果有人键入www.domain1.com/1234,它会在重定向时自动将12345附加到重定向URL,这样它就会转到www.domain2.com/subdomain=1345

即它们附加到原始重定向的任何内容都将被附加到新重定向(之前没有/)。

您应该使用RedirectMatch而不是Redirect。参见手动

资源已移动到另一个服务器

#With RedirectMatch RedirectMatch "^/docs/(.*)" "http://new.example.com/docs/$1"

在您的情况下:

RedirectMatch ^/(.*)$ http://www.domain2.com/subdomain=$2