2012-05-07 122 views
0

我试图在Web服务器上安装Symfony2,但我有一个关于URL的问题。在Web服务器上安装Symfony2

我想安装它在这个网址。

http://mywebsite.com/gestor 

因此,可以放在/ web文件夹分配的文件放到这个目录(gestor),并把其他人(/应用程序,/ bin中,/ src目录...)在另一条路径的服务器(一个让他们私人的,也不可能获得通过URL?

这是最好的办法吗?只要做到这一点,并修改app.php要求?

回答

0

我会尽力帮助你,但我不是真正的专家在这个话题上?你在共享或专用主机上安装?

如果你是在一个专用主机,你可以去here

但我假设你是一个共享的主机(KBrogan提供)安装: 任何人都可以点我如何mod_rewrite的www.site.com/appname/web/app.php到更性感网址www.site.com会自动重定向到www.site.com/appname ...而不检查URL到长版本?

<bernardnapoleon> i've been googling for hours now. >>< 
<helios_ag> r u on shared hosting? 
<bernardnapoleon> yes 
<KBrogan> bernard, i have just the solution for you if you would like everything redirected to site.com/index.php with your content stored in webroot/Symfony 
<bernardnapoleon> really? you're amazing! 
<bernardnapoleon> that's it 
<KBrogan> 1) move Symfony/web to webroot/ 
<bernardnapoleon> okay but wouldn't that break the folder structure of symfony? 
<KBrogan> nope 
<KBrogan> 2) change the require_once tags in both files webroot/app(_dev)?.php to point to Symfony/app/... instead of pointing to ../Symfony/app 
<KBrogan> example: require_once __DIR__.'/Symfony/app/AppKernel.php'; 
<bernardnapoleon> oks! done 
<KBrogan> make .htaccess in webroot this: 
<KBrogan> RedirectMatch 404 "^/Symfony(/.*)?$" 
<KBrogan> RedirectMatch 404 "/\..*" 
<KBrogan> RedirectMatch 404 "/(config||app(_dev)?).php" 
<KBrogan> <IfModule mod_rewrite.c> 
<KBrogan>  RewriteEngine On 
<KBrogan>  RewriteCond %{REQUEST_FILENAME} !-f 
<KBrogan>  RewriteRule ^(.*)$ index.php [QSA,L] 
<KBrogan> </IfModule> 
<KBrogan> last step - make a symlink index.php => app_dev.php 
<bernardnapoleon> ohhhhhhhhhhhhhhhhhhhhhhhhhh................... 
<KBrogan> Do you have shell access on your host bernard? 
<bernardnapoleon> nope 
<helios_ag> not good idea to publish dev env on prod env 
<bernardnapoleon> helios_ag: yep yep. 
<KBrogan> dev env ip blacklists itself. Not really an issue until you've deployed 
<bernardnapoleon> KBrogan: Thank you! 
<bernardnapoleon> i'll just rename app.php to index.php incase i can't do symlink 
<KBrogan> if you don' t have shell access: either make a link with php, or rename the app.php 
<bernardnapoleon> yeah. Thanks Again Bro 
<bernardnapoleon> =) 
<bernardnapoleon> all this time I thought the answer is in mod_rewrite 
<KBrogan> i'm quite happy with the results there. Spent a couple of hours tweaking it 
<KBrogan> I've got shell access, so I set up an alias dev and an alias prod which switches the environment for me and clears the cache 
<KBrogan> Question: is there a twif filter which pretty prints all your html? 
<KBrogan> twig* 
<bernardnapoleon> oh cool. 
<bernardnapoleon> not an expert but I think you have to post process that. 
<KBrogan> by the way bernard, the RedirectMatch 404 "/\..*" bit will hide all of your .htaccess files and make them return 404 instead of 403 
<KBrogan> as well as any other file that stats with . 
<KBrogan> and any other file besides /Symfony/* , index.php, app_dev.php, app.php, will be served directly by Apache 
<bernardnapoleon> ohhhh 
相关问题