将子域的子目录的规则重写到另一个子目录

时间:2020-04-13 22:08:08

标签: .htaccess mod-rewrite

我有subdomain test.mydomain.com,主应用程序正在test.mydomain.com上运行。

当用户访问http://test.mydomain.com/portal时,我需要重定向到/users/test/cp子目录,而无需更改url

我已经写了htaccess,但是CSS和javascript没有加载,显示302响应

    RewriteEngine On
 RewriteBase /
RewriteCond %{HTTP_HOST} ([^\.]+).mydomain.* [NC]
RewriteRule ^/?portal/(.*)$ /users/%1/cp/$2 [L]

1 个答案:

答案 0 :(得分:0)

我找到了答案,我犯了个小错误。

    RewriteEngine On
 RewriteBase /
RewriteCond %{HTTP_HOST} ([^\.]+).mydomain.* [NC]
RewriteRule ^/?portal/(.*)$ /users/%1/cp/$1 [L]