URL重写不会在Symfony2的工作 [英] URL rewrite doesn't work in a Symfony2

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

问题描述

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

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

阿帕奇mod-rewrite已启用。阿帕奇已经重新启动多次。

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

# a2enmod rewrite
Module rewrite already enabled

虚拟主机似乎确定

Virtual host seems ok

<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/ 给在网页指数,我必须通过< A HREF =htt​​p://mydomain.com/app.php/相对=nofollow> 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无的AllowOverride全部

当此指令设置为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 设置为

http://httpd.apache.org/docs/current/ MOD / core.html#的AllowOverride

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

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