需要修复 Apache 配置

需要修复 Apache 配置

问题:我已将 Wordpress MU 加载到我的 DocumentRoot 中。这工作正常,但是,我现在在 DocumentRoot 中有两个项目,它们都具有同名的目录:“plugins”:/var/www/html/cms/plugins/ /var/www/html/cms/sites/blogs/wp-content/plugins/。我相信由于我当前的 Apache 设置,这会导致冲突。当我加载 WP MU 并登录时,一切“似乎”正常,但仔细观察后,我发现由于 Apache 404 错误,没有一个插件正在加载。示例: https://www.someplaceonline.ext/blogs/wp-content/plugins/active-directory-integration/css/adintegration.css?ver=1.7.1

404 未找到。

我不确定如何修复此问题,因此我提供了我的 Apache 设置。

我已经尝试过的方法:将“ AliasMatch ^.*/plugins/(.*)$ /var/www/html/cms/plugins/$1”改为AliasMatch ^\.\./plugins/(.*)$ /var/www/html/cms/plugins/$1。原因:我的 cms 目录中对其“插件”的引用通常以“..”为前缀,因此它们的格式为 ../plugins/someplugin/etc/etc.ext 这样可以继续在 cms 中正确加载插件,并验证我的正则表达式http://www.regextester.com/让我相信这一点应该努力解决问题,但是,诸如https://www.someplaceonline.ext/blogs/wp-content/plugins/active-directory-integration/css/adintegration.css?ver=1.7.1继续加载失败。

添加“ AliasMatch ^.*/wp-content/plugins/(.*)$ /var/www/html/cms/sites/blogs/wp-content/plugins/$1”。我以为我可以简单地添加一个新的 AliasMatch 来解析 Wordpress 的路径映射,但这也不起作用。

相关目录结构:

/var/www/html/
/var/www/html/cms/
/var/www/html/cms/memorybook/
/var/www/html/cms/plugins/
/var/www/html/cms/site_resources/
/var/www/html/cms/sites/
/var/www/html/cms/sites/blogs/

相关Apache配置:

<VirtualHost *:80>
    DocumentRoot /var/www/html/cms/sites/

    #Host names
    ServerName www.someplaceonline.ext
    ServerAlias someplaceonline.ext
    ServerAlias www.spo.ext
    ServerAlias spo.ext

    <Directory "/var/www/html/cms/sites/">
       AllowOverride All
       Allow from All
    </Directory>

    ### This set of directives match the blogs on this server, which is outside of the document root. ###
    Alias /blogs /var/www/html/cms/sites/blogs
    <Directory "/var/www/html/cms/sites/blogs">
        AllowOverride All
        Allow from All
    </Directory>

    ### This set of directives match the memorybook folder which is outside of the doucment root. ###
    Alias /memorybook /var/www/html/memorybook
    <Directory "/var/www/html/memorybook">
        AllowOverride All
        Allow from All
    </Directory>

    ### This set of directive match the plugins folder which is outside of the document root. ###
    #Alias /plugins /var/www/html/cms/plugins
    #<Directory "/var/www/html/cms/plugins">
    #   AllowOverride All
    #   Allow from All
    #</Directory>

    ### This set of directive match the site_resources folder which is outside of the document root. ###
    Alias /site_resources /var/www/html/cms/site_resources
    <Directory "/var/www/html/cms/site_resources">
       AllowOverride All
       Allow from All
    </Directory>

    ### This must be last or else unwanted matches will occur. ###
    AliasMatch ^.*/site_resources(.*)$ /var/www/html/cms/site_resources/$1
    AliasMatch ^.*/plugins/(.*)$ /var/www/html/cms/plugins/$1
    #AliasMatch ^.*/wp-content/plugins/(.*)$ /var/www/html/cms/sites/blogs/wp-content/plugins/$1
</VirtualHost>

答案1

### This set of directives match the blogs on this server,
###     which is outside of the document root.
Alias /blogs /var/www/html/cms/sites/blogs
<Directory "/var/www/html/cms/sites/blogs">
    AllowOverride All
    Allow from All
</Directory>

不,这是多余的,因为 /blogs 是已经等于 /var/www/html/cms/sites/blogs。

AliasMatch ^.*/site_resources(.*)$ /var/www/html/cms/site_resources/$1

也是其先前的目录块和别名定义的副本。
如果您想要这个上班,消除别名。

AliasMatch ^.*/plugins/(.*)$ /var/www/html/cms/plugins/$1

与上面相同,添加酱汁绝不最终到达 /var/www/html/cms/sites/blogs/wp-content/plugins/

请注意别名应该以斜线结尾,除非您知道更好的方法(但您不知道)。

删除上面的前两部分,然后告诉我们当您尖叫“404!”时错误日志说了什么。

相关内容