Symfony Ignore Directory in web/

心已入冬 提交于 2019-11-30 16:14:19

问题


In an symfony project, is there any way to exclude a directory from being processed.

For example, I want to run a seperate php program in mysite.com/other_app

How can I exclude web/other_app folder from being processed by the symfony controller.

I've tried using

RewriteCond %{REQUEST_URI} !^/other_app/(.*)$

and

RewriteCond %{REQUEST_FILENAME} !-d

Symfony still processes the other_app which obviously isn't going to work properly. Any suggestions.Do I need to modify htaccess in other_app/.htaccess as well?

Also, let me add. When I access just the directory mysite.com/other_app I get the correct content. If I try and access anything below that, I get problems.

This works: mysite.com/other_app

This does not: mysite.com/other_app/page1

In the logs I get an error: Action "other_app/page1" does not exist. Or something similar.


回答1:


Ok. I figured it out. The .htaccess of the sub directory also needs to be modified.

In web/.htaccess use:

RewriteCond %{REQUEST_FILENAME} !-d

In the sub directory, web/other_app/.htaccess use:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /other_app/index.php [QSA,L]

This will work for wordpress and most any other php app that you want to run on a symfony site, but don't want to deal with trying to hack it into the framework.




回答2:


Try adding:

RewriteCond %{REQUEST_FILENAME} !-d


来源:https://stackoverflow.com/questions/7728265/symfony-ignore-directory-in-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!