URL重定向子目录子域子目录、重定向、URL

2023-09-02 00:46:27 作者:迷离的眼

我使用的PHP。我想重定向子目录子域和子目录子目录子域目录。

I am using php. and i want to redirect subdirectory to subdomain and subdirectory of subdirectory to subdomain directory.

例如:如果我有URL如 http://www.test.com/test1/

For example : if i have url like http://www.test.com/test1/

那么它应该重定向到 http://test1.test.com/

和第二,如果我有URL像这样 http://www.test.com/test1/test2 /

and second if i have url like this http://www.test.com/test1/test2/

那么它应该重定向到 http://test1.test.com/test2/

任何一个有想法如何做到这一点。

Any one have idea how to do this.

在此先感谢

推荐答案

可以在.htaccess做类似的东西。

can do in .htaccess with something like..

RewriteEngine On
RewriteRule ^([^/]+)/(.*)$ http://$1.test.com/$2 [R,L]