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动图的问题
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名