【问题标题】:.htaccess with SilverStripe and WordPress.htaccess 与 SilverStripe 和 WordPress
【发布时间】:2012-06-06 19:10:26
【问题描述】:

好的,基本上我需要能够设置我的 .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 ###

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

谢谢, 杰赫

【问题讨论】:

    标签: wordpress .htaccess silverstripe


    【解决方案1】:

    一个简单的建议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
    

    【讨论】:

    • 好的,大部分都可以。例如,所有 SilverStripe 的东西看起来都很好。永久链接的类别和帖子很好。但是除了最初的 index.php 之外,访问 blogs 子目录中的实际 php 文件不起作用(即 ../blogs/aquiman/wp-login.php 不起作用),并且似乎找不到 CSS 页面。有什么想法吗?
    • 我收回了。我猜博客看到的是旧的缓存版本。在 blogs 子目录中没有任何作用。
    • 好的,博客回来了,但没有 CSS。但是,现在 Silverstripe 显示在主页上,但您没有子页面或无法登录管理页面。
    • 进行了另一次编辑。你的 css 没有为 WP 或 Silverstrip 显示?确保你的 CSS 补丁是绝对的而不是相对的。
    • 好的,我不需要最后的编辑。应该是缓存问题。因为当我开始我的第二份工作时,我把它装上去看看它是否能工作,而且一切正常。所以,谢谢!!!
    猜你喜欢
    • 2017-07-03
    • 1970-01-01
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    相关资源
    最近更新 更多