2

好的,基本上我需要能够设置我的 .htaccess 以便它适用于根目录中的 SilverStripe 安装和 /blogs 目录中安装的博客。这是我所拥有的:

### SILVERSTRIPE START ###
<Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Files>

<Files web.config>
    Order deny,allow
    Deny from all
</Files>

ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_alias.c>
    RedirectMatch 403 /silverstripe-cache(/|$)
</IfModule>

<IfModule mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE On
    RewriteEngine On

    # BEGIN Silverstripe
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    # END Silverstripe

    # BEGIN WordPress
    RewriteBase /blogs/aquiman/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blogs/aquiman/index.php [L]

    RewriteBase /blogs/aquipad/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blogs/aquipad/index.php [L]
    # END WordPress

</IfModule>
### SILVERSTRIPE END ###

这当然行不通。我知道这是错误的,但我知道的还不够多,无法修复它。请帮助我更正此问题以使其正常工作。

谢谢,JH

4

1 回答 1

4

一个简单的建议,keep it separate

  • SilverStripe将相关代码保存$DOCUMENT_ROOT/.htaccessRewriteBase /
  • Wordpress将相关代码保存$DOCUMENT_ROOT/blog/.htaccessRewriteBase /blog/

这是您应该使用的修改后的重写代码$DOCUMENT_ROOT/.htaccess:

# BEGIN Silverstripe
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule (?!^blog/)^.*$ sapphire/main.php?url=$1 [L,QSA,NC]
# END Silverstripe
于 2012-06-06T19:24:09.997 回答