Symfony2-将/ web目录重定向到根目录 [英] Symfony2 - redirect /web directory to root

查看:82
本文介绍了Symfony2-将/ web目录重定向到根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Symfony2 Projet出现重复的内容问题。以下网址具有相同的内容:

I've got a duplicate content problem with my Symfony2 projet. The following urls gives the same content :

www.mywebsite.com/web/page www.mywebsite.com/page

这是我的 /。htaccess 文件:

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

以及我 /web/.htaccess的内容文件:

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

我想重定向任何以 / web / ,但我无法做到。你有什么建议吗?

I would like to redirect any url starting with /web to / but I can't manage to do it. Do you have any suggestion ?

推荐答案

在您的Web目录中的htaccess文件中( /web/.htaccess 文件),将这些规则添加到 RewriteEngine On 下方:

In the htaccess file in your web directory (the /web/.htaccess file), add these rules right beneath the RewriteEngine On:

RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /web/
RewriteRule ^(.*)$ /$1 [L,R=301]

这会将所有对Web目录的直接访问重定向到根。

This redirects all direct access to the web directory to the root.

这篇关于Symfony2-将/ web目录重定向到根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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