简体   繁体   English

共享主机中的symfony2的htaccess

[英]htaccess for symfony2 in shared hosting

i have a shared hosting. 我有一个共享主机。 I want to see a example of .htaccess file in public_html folder to setup a symfony2 application(the entry point is web/app.php) Thanks a lot in advance 我想在public_html文件夹中查看.htaccess文件的示例来设置symfony2应用程序(入口点是web / app.php),非常感谢

The symfony standard edition already contains a .htaccess which you can use. 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>

Try this: 尝试这个:

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>

Set it up on the root folder, one level above public_html . 将其设置在根文件夹上,位于public_html之上的一级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM