2017-04-06 237 views
1

我需要打開訪問以下文件夾給大家:的Symfony允許文件資源的訪問文件夾的.htaccess

C:\xampp\htdocs\myapp\app\Resources\export 

,但我得到403 Forbidden錯誤。我嘗試了很多變種,但仍然沒有運氣。我的.htaccess它位於

C:\xampp\htdocs 

如下:

<IfModule mod_rewrite.c> 
Options +FollowSymlinks 
RewriteEngine On 

# Explicitly disable rewriting for front controllers 
RewriteRule ^app_dev.php - [L] 
RewriteRule ^app.php - [L] 

# Fix the bundles folder 
RewriteRule ^bundles/(.*)$ /myapp/web/bundles/$1 [QSA,L] 
RewriteRule ^js/(.*)$ /myapp/web/js/$1 [QSA,L] 
RewriteRule ^css/(.*)$ /myapp/web/css/$1 [QSA,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ /myapp/web/app.php [QSA,L] 
RewriteRule (.*) $1 [E=SYMFONY_ENV:prod] 

任何想法將受到歡迎。謝謝。

回答

1

問題是您的服務器的DocumentRoot指向/web目錄,而/app目錄超出了範圍。也許你可以使用別名解決這個問題:

Alias /export "C:/xampp/htdocs/myapp/app/Resources/export" 
<Directory "C:/xampp/htdocs/myapp/app/Resources/export"> 
    Options Indexes 
    AllowOverride None 
    Require all granted 
</Directory> 

當使用alias你必須前綴與別名資源的途徑。

例如用於獲取resoource test.jpg放在位於:

C:/xampp/htdocs/myapp/app/Resources/export/test.jpg 

你的要求應該是這樣的:

http://yourServerName/export/test.jpg 

此類路由的問題是,Symfony的路由不能管理它,因爲有服務器範圍外,但你可以使用主機匹配,看到這個問題:

Routing prefix as follows the Virtual Host

如果您使用別名記住啓用別名模塊,如果它被禁用。

希望它有幫助。

+0

不幸的是,這不起作用。說500錯誤。 – Jack

+0

我用另一種方法更新了我的答案。 – Hokusai

相關問題