SilverStripe Root中的vbulletin论坛 - url misdirection

时间:2016-07-31 22:33:23

标签: .htaccess silverstripe

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

但是,该网址会自动附加./?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错误。

我们如何修复此错误的网址重定向问题?

1 个答案:

答案 0 :(得分:1)

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

要检查这一点,我们会将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网址和任何子网址的访问。这允许我们将任何其他应用程序或代码放入此目录。

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

RewriteRule ^community - [L,NC]