symfony2 重写规则 .htaccess app.php [英] symfony2 rewrite rules .htaccess app.php

查看:27
本文介绍了symfony2 重写规则 .htaccess app.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的 symfony2 项目上传到 server grove.主页已加载,但所有链接均已损坏.我尝试将 app.php 添加到网址.它确实有效,但是:

I uploaded my symfony2 project to server grove. The main page loads, but all the links are broken. I tried adding app.php to the web address. It did work, but:

我有这样的路线:

www.something.com/app.php/something

www.something.com/app.php/something

我希望他们成为:

www.something.com/something.

www.something.com/something.

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

I've been reading, and I should put some rewrite rules on the .htaccess.

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

I found these rules, but they don't seem to work:

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

推荐答案

在你的 .htaccess 文件(在 web 目录中)试试这个:

Try this in your .htaccess file (inside the web directory):

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # Explicitly disable rewriting for front controllers
    RewriteRule ^app_dev.php - [L]
    RewriteRule ^app.php - [L]

    RewriteCond %{REQUEST_FILENAME} !-f

    # Change below before deploying to production
    #RewriteRule ^(.*)$ /app.php [QSA,L]
    RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>

这篇关于symfony2 重写规则 .htaccess app.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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