1

我有一个共享主机。我想在 public_html 文件夹中查看 .htaccess 文件的示例来设置 symfony2 应用程序(入口点是 web/app.php) 提前非常感谢

4

2 回答 2

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>
于 2013-06-13T06:46:12.937 回答
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

于 2013-11-03T15:14:45.743 回答