2016-07-31 79 views
2

我們在SilverStripe根目錄下安裝了vBulletin 5安裝,加載到名爲社區的文件夾中。因此社區索引文件的URL應爲:www.e-lumini.com/communitySilverStripe Root內的vbulletin論壇 - 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重定向問題?

+0

我想你忘了張貼代碼。 – RamenChef

回答

1

我們可以將main.phpRewriteRule更改爲在將請求重定向到SilverStripe的框架main.php文件之前檢查URL是否以/community開頭。

要檢查這一點,我們添加RewriteCond %{REQUEST_URI} !/community我們.htaccessRewriteRule這樣的:

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

這將停止SilverStripe重定向訪問community URL和所有子網址。這使我們可以將任何其他應用程序或代碼放入此目錄中。

我們還需要刪除以下規則,因爲這將阻止所有訪問該社區網址:

RewriteRule ^community - [L,NC]