2013-06-13 44 views
1

我有一个共享的托管。 我希望看到.htaccess文件的一个例子的public_html文件夹设置一个Symfony2的应用程序(入口点是网/ app.php) 感谢很多提前共享主机中的symfony2 htaccess

+0

https://github.com/symfony/symfony-standard/blob/master/web/.htaccess - 此外,没有SSH访问,使用Symfony将是痛苦的 –

回答

0

symfony的标准版中已经包含了.htaccess你可以使用。

DirectoryIndex app.php 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 
    RewriteRule ^(.*) - [E=BASE:%1] 
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] 
    RewriteCond %{REQUEST_FILENAME} -f 
    RewriteRule .? - [L] 
    RewriteRule .? %{ENV:BASE}/app.php [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
    <IfModule mod_alias.c> 
     RedirectMatch 302 ^/$ /app.php/ 
    </IfModule> 
</IfModule> 
+2

但这是web文件夹中的.htaccess ,我需要一个.htaccess来放置在symfony2项目所在的public_html目录中 – Oriam

0

试试这个:

DirectoryIndex public_html/app.php 

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteCond %{REQUEST_URI} !^/public_html/ 
    RewriteRule (.*) /public_html/$1 
</IfModule> 

<IfModule !mod_rewrite.c> 
    <IfModule mod_alias.c> 
     # When mod_rewrite is not available, we instruct a temporary redirect of 
     # the start page to the front controller explicitly so that the website 
     # and the generated links can still be used. 
     RedirectMatch 302 ^/$ /public_html/app.php/ 
     # RedirectTemp cannot be used instead 
    </IfModule> 
</IfModule> 

设置它的根文件夹,上面public_html一个级别。