symfony2重写规则.htaccess app.php

我将symfony2项目上传到服务器grove。主页已加载,但所有链接均已断开。我尝试将app.php添加到网址。它确实起作用,但是:


我有这样的路线:


www.something.com/app.php/something


我希望他们是:


www.something.com/something。


我一直在阅读,我应该在.htaccess上放一些重写规则。


我找到了这些规则,但它们似乎不起作用:


<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ app.php [QSA,L]

</IfModule>


智慧大石
浏览 675回答 3
3回答

潇潇雨雨

在您的.htaccess文件(在Web目录内)中尝试以下操作:<IfModule mod_rewrite.c>&nbsp; &nbsp; Options +FollowSymlinks&nbsp; &nbsp; RewriteEngine On&nbsp; &nbsp; # Explicitly disable rewriting for front controllers&nbsp; &nbsp; RewriteRule ^app_dev.php - [L]&nbsp; &nbsp; RewriteRule ^app.php - [L]&nbsp; &nbsp; RewriteCond %{REQUEST_FILENAME} !-f&nbsp; &nbsp; # Change below before deploying to production&nbsp; &nbsp; #RewriteRule ^(.*)$ /app.php [QSA,L]&nbsp; &nbsp; RewriteRule ^(.*)$ /app_dev.php [QSA,L]</IfModule>

SMILET

为了提高惠斯勒格雷格的答案,我添加了一行,以使bundles文件夹不损坏。这将确保外部资源(例如图像)不会损坏。<IfModule mod_rewrite.c>&nbsp; &nbsp; Options +FollowSymlinks&nbsp; &nbsp; RewriteEngine On&nbsp; &nbsp; # Explicitly disable rewriting for front controllers&nbsp; &nbsp; RewriteRule ^/web/app_dev.php - [L]&nbsp; &nbsp; RewriteRule ^/web/app.php - [L]&nbsp; &nbsp; # Fix the bundles folder&nbsp; &nbsp; RewriteRule ^bundles/(.*)$ /web/bundles/$1&nbsp; [QSA,L]&nbsp; &nbsp; RewriteCond %{REQUEST_FILENAME} !-f&nbsp; &nbsp; # Change below before deploying to production&nbsp; &nbsp; #RewriteRule ^(.*)$ /web/app.php [QSA,L]&nbsp; &nbsp; RewriteRule ^(.*)$ /web/app_dev.php [QSA,L]</IfModule>
打开App,查看更多内容
随时随地看视频慕课网APP