Symfony2-将/ web目录重定向到根目录 [英] Symfony2 - redirect /web directory to root
问题描述
我的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 $ c的内容$ c>文件:
<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 $ c开头的URL $ c>到
/
,但我无法做到。你有什么建议吗?
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屋!