2011-03-08 28 views
1

我试图建立一个模块来管理文件的下载,所以当有人转到site.com/download/filename.pdf时,它会使用filename参数激活下载模块,如下所示: filename.pdf。如何让Symfony允许文件名作为模块的参数

问题是关于Symfony的重写规则不允许,它会被重写。我需要添加到.htaccess才能防止重写.doc和.pdf文件的这些URL。我已经包含下面的.htaccess文件...

感谢您的帮助!

S 

Options +FollowSymLinks +ExecCGI 

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    # uncomment the following line, if you are having trouble 
    # getting no_script_name to work 
    RewriteBase/



    # we check if the .html version is here (caching) 
    RewriteRule ^$ index.html [QSA] 
    RewriteRule ^([^.]+)$ $1.html [QSA] 
    RewriteCond %{REQUEST_FILENAME} !-f 

    # no, so we redirect to our front web controller 
    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 

回答

1

创建一个通配符路线:

url: /download/* 

并将其指向的下载模块。无论以/ download /开头的任何路由将自动打开您的下载模块。

0

感谢乔恩, 补充说,我也不得不改变路线上的segment_separators停止。被解释为另一个参数的标记,因此将其添加到route.yml中此模块的路由中: segment_separators:[' - ','/','_']