.htaccess Symfony mod_仅重写主路线有效

.htaccess Symfony mod_仅重写主路线有效,.htaccess,mod-rewrite,symfony,.htaccess,Mod Rewrite,Symfony,我想用mod_重写。我已在/var/www/.htaccess中访问此代码 <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On #AllowOverride All #Allow from All #RewriteBase /WorldClock #RewriteBase WorldClock/web/app.php # Explicitly

我想用mod_重写。我已在/var/www/.htaccess中访问此代码

<IfModule mod_rewrite.c>

    Options +FollowSymlinks
    RewriteEngine On
    #AllowOverride All

    #Allow from All  
    #RewriteBase /WorldClock
    #RewriteBase WorldClock/web/app.php
    # Explicitly disable rewriting for front controllers
    RewriteRule ^/web/app_dev.php - [L]
    RewriteRule ^/web/app.php - [L]

    # Fix the bundles folder
    #RewriteRule ^(.*)$ WorldClock/web/app.php/test [QSA,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    # Change below before deploying to production
    RewriteRule ^(.*)$ WorldClock/web/app.php [QSA,L]
    #RewriteRule ^(.*)$ WorldClock/web/app_dev.php [QSA,L]

</IfModule>

没有访问权限,一切正常。phpinfo()中的Mod_rewrite处于启用状态;我使用symfony2和Ubuntu来帮助我们,至少我们需要您的web服务器的配置。我认为这仅仅是web服务器没有正确配置的问题。如果我不想回答您的问题,请用有意义的错误消息更新您的问题,即检查您的error.log以及关于哪些路由有效,哪些路由无效的更详细描述,因为我不完全确定您是否可以访问localhost并查看默认的“It work's”页面或项目的frontpage,以及您是否可以访问您的资产

只需在
/etc/apache2/sites available/
中创建一个新文件
worldclock.conf

<VirtualHost *:80>
    ServerName localhost

    DocumentRoot /var/www/WorldClock/web
    <Directory /var/www/WorldClock/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>
</VirtualHost>
如果这只是您的开发环境,那么您可以使用PHP的内部web服务器(假设已安装5.4),这将简化一些所需的工作,因为您只需运行:
PHP应用程序/控制台服务器:run
,即可使其运行。然后您可以通过:
http://localhost:8000默认情况下,

要了解安装了哪个PHP版本,只需在终端中运行:
PHP-v

<VirtualHost *:80>
    ServerName localhost

    DocumentRoot /var/www/WorldClock/web
    <Directory /var/www/WorldClock/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>
</VirtualHost>
sudo a2ensite worldclock

# When both hosts use localhost as ServerName there might be some problems
# so we'll disable the default host, which we won't need anyway(?)
sudo adissite default

sudo service apache2 restart