vbulletin论坛在SilverStripe根-网址误导



我们在SilverStripe根目录中安装了vBulletin 5,加载到名为community的文件夹中。因此,社区索引文件的url应该是:www.e-lumini.com/community

然而,url会自动附加./?url=/community(完全显示为http://e-lumini.com/community/?),当然,它会重定向到404页面。

据推测,这是一个.htaccess内容问题。

这是我们当前的SilverStripe.htaccess文件

### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
# Deny access to IIS configuration
<Files web.config>
Order deny,allow
Deny from all
</Files>
# Deny access to YAML configuration files which might include sensitive    
information
<Files *.yml>
Order allow,deny
Deny from all
</Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache =2.4
<IfModule mod_dir.c>
    DirectoryIndex disabled
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/'
# Deny access to potentially sensitive files and folders
RewriteRule ^community - [L,NC]
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer.(json|lock) - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* framework/main.php?url=%1 [QSA]
</IfModule>
### SILVERSTRIPE END ###

请注意上面包含的社区重写规则,它现在导致403错误。

我们如何解决这个不正确的url重定向问题?

在将请求重定向到SilverStripe的框架main.php文件之前,我们可以更改main.php RewriteRule以检查URL是否以/community开头。

为了检查这一点,我们将RewriteCond %{REQUEST_URI} !/community添加到我们的.htaccess RewriteRule中,如下所示:

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/community 
RewriteRule .* framework/main.php?url=%1 [QSA]

这将停止SilverStripe重定向对community URL和任何子URL的访问。这允许我们将任何其他应用程序或代码放入该目录。

我们还需要删除以下规则,因为这会阻止对社区URL的所有访问:

RewriteRule ^community - [L,NC]

最新更新