【问题标题】:How to render a page on a WordPress website for a subdomain using htaccess如何使用 htaccess 在 WordPress 网站上为子域呈现页面
【发布时间】:2013-07-11 11:16:29
【问题描述】:

我正在开发一个具有多个子域的网站,例如 country1.example.com、country2.example.com 等。我正在使用 WordPress 开发此网站,并希望将子域映射到特定页面。例如对于子域india.example.com 我想渲染example.com/countries/india

为此,我已经完成以下操作,但它不适用于所有子域,它显示相同的主页

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(^.*)\.exapmle.com
RewriteRule (.*)  countries/%1

我如何使用 htaccess 来做到这一点,因为我完全不了解 htaccess 编程。

【问题讨论】:

    标签: php wordpress .htaccess url-rewriting


    【解决方案1】:

    试试这个:

    RewriteCond %{HTTP_HOST} !^(www)\. [NC]
    RewriteCond %{HTTP_HOST} ^(.*)\.example\.com [NC]
    RewriteRule (.*) http://www.example.com/countries/%1/$1 [L]
    

    它还会将 india.example.com/test.html 重定向到 www.example.com/india/test.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-11
      • 1970-01-01
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-22
      • 2018-11-09
      相关资源
      最近更新 更多