2

我的主要域是一个 Wordpress 博客,它的 .htaccess 重写如下......

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

这很好用,但我在同一个目录中有一个子域,并且正在使用这个重写......

    RewriteCond %{SERVER_PORT} ^443$
    RewriteCond %{HTTP_HOST} ^my\.domain\.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/my/
    RewriteRule ^(.*) /my/$1

那是我的通配符 SSL 证书。这很好用,但如果子域中不存在该位置,我会得到 wordpress 的错误页面。我需要 wordpress 重写以忽略“我的”子域。我怎样才能做到这一点?

我在想类似的东西......

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

但这不起作用,也试过这个....

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

有任何想法吗?

4

1 回答 1

5

您可能应该通过在服务器名称上添加条件来忽略域。

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

另外,我前段时间遇到的一件事情,尝试将子域的 htaccess 更改为

RewriteBase /my 

如果“我的”是它所在的目录。

于 2012-10-07T14:10:27.833 回答