如何将子域重定向到特定文件夹?

时间:2021-04-07 18:29:43

标签: .htaccess dns subdomain

我创建了一个名为 services 的子域,我想将它重定向到一个文件夹,但我无法让它工作。

我试过了:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

RewriteCond %{HTTP_HOST} ^services\.\.com.br$
RewriteRule ^/$ http://subdomain.mydomaintest/services/ [R,L]

文件夹的路径是 mydomain/web/services

1 个答案:

答案 0 :(得分:2)

这应该适合你:

# subdomain to subfolder
RewriteEngine on
RewriteCond %{HTTP_HOST} ^services\.com.br$
RewriteRule !service /services%{REQUEST_URI} [L]

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress