【问题标题】:How to redirect subdomain to a specific folder?如何将子域重定向到特定文件夹?
【发布时间】:2021-07-03 14:55:03
【问题描述】:

我创建了一个名为 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

【问题讨论】:

    标签: .htaccess dns subdomain


    【解决方案1】:

    这应该适合你:

    # 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
    

    【讨论】:

    • 工作需要时间还是应该立即工作?我之所以问,是因为我尝试使用您的代码,但它不起作用,浏览器返回“嗯……无法访问此页面”:'(
    • @Lucky 它应该可以立即工作。你要去哪个网址?
    • 我收到“嗯……无法访问此页面”和 DNS_PROBE_FINISHED_NXDOMAIN”
    猜你喜欢
    • 2014-01-16
    • 2013-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-03
    • 1970-01-01
    • 2018-03-08
    • 1970-01-01
    相关资源
    最近更新 更多