dsaeyrq451928 2017-04-06 17:01
浏览 79
已采纳

Symfony允许在Resources文件夹.htaccess中访问文件

I need to open access to the following folder for everyone:

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

but I get 403 Forbidden error. I tried many variants but still no luck. My .htaccess which is located at

C:\xampp\htdocs

is as follows:

<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]

Any ideas would be welcome. Thank you.

  • 写回答

1条回答 默认 最新

  • dongwo5110 2017-04-06 19:20
    关注

    The problem is that DocumentRoot of your server is pointing to /web directory and /app directory is out of scope. Maybe you can solve it using an alias:

    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>
    

    When using alias you must to prefix the route to the resource with the alias name.

    For example for getting the resoource test.jpg located in:

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

    Your request should be like:

    http://yourServerName/export/test.jpg
    

    The problem of this type of routes is that Symfony routing can't managed it because there are out of server scope, but you can use host-matching, see this question:

    Routing prefix as follows the Virtual Host

    If you use alias remember enable alias module if it is disabled.

    Hope it helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题