0

I've got a Symfony 2 project and I had to use a .htaccess config to hide the front file and the web directory, but in the process it means I can't access the public uploads folder I created. Is there way I can create a symlink or exception for that route?

Here's my current .htaccess

   <IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

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

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

    RewriteCond %{REQUEST_FILENAME} !-f
    # Change below before deploying to production
    RewriteRule ^(.*)$ /web/app.php [QSA,L]
    #RewriteRule ^(.*)$ /web/app_dev.php [QSA,L]
</IfModule>

Thanks in advance!

4

2 回答 2

1

您可以添加一个例外来不重写某个文件夹,就像您为前端控制器禁用重写一样。只需添加RewriteRule ^path-to-folder/.* - [L]它们即可访问文件夹路径中的文件。

于 2013-07-18T20:43:58.903 回答
0

您可以创建一个例外,就像您已经做过的那样:

#disable redirecting for all the files in /web/upload dir
RewriteRule ^web/upload/.* - [L]

把它放在 .htaccess 的开头,它会在重定向发生之前停止处理。有一件事,我不明白,为什么开头有一个额外的斜线:^/web. 因为在 .htaccess 条件中应该省略第一个斜杠。

于 2013-07-18T20:58:19.020 回答