URL重写在Symfony2中不起作用 [英] URL rewrite doesn't work in a Symfony2

查看:63
本文介绍了URL重写在Symfony2中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Symfony 2下有一个网站,希望重写基本的URL.

I have a web site under Symfony 2 and want to have a basic URL rewrite.

Apache mod重写已启用.Apache已多次重启.

Apache mod rewrite is enabled. Apache has been restarted multiple times.

# a2enmod rewrite
Module rewrite already enabled

虚拟主机似乎还可以

<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com

    DocumentRoot /home/www/mydomain/web
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/www/mydomain/web>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这是我的.htacess

And here's my .htacess

<IfModule mod_rewrite.c>
    RewriteEngine On

    #<IfModule mod_vhost_alias.c>
    #    RewriteBase /
    #</IfModule>

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

但是 http://mydomain.com/给出了索引"页面,我必须通过 http://mydomain.com/app.php/来访问我的网站.

But http://mydomain.com/ gives the "index of" page and I have to pass through http://mydomain.com/app.php/ to access my web site.

我想念什么?!

推荐答案

您需要将 AllowOverride None 更改为 AllowOverride All

当此伪指令设置为None且AllowOverrideList设置为时没有.htaccess文件,将被完全忽略.在这种情况下,服务器甚至不会尝试读取文件系统中的.htaccess文件.

When this directive is set to None and AllowOverrideList is set to None .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.

未指定时, AllowOverrideList 设置为 None

http://httpd.apache.org/docs/current/mod/core.html#allowoverride

这篇关于URL重写在Symfony2中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆