htcaccess和symfony 2重定向非www->万维网 [英] htcaccess and symfony 2 redirect non www -> www
本文介绍了htcaccess和symfony 2重定向非www->万维网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有个小问题。
我为我的域创建了从非www到www的重定向。
一切正常,但重定向后我得到了索引文件(app.php),我不知道为什么。
I create redirect for my domain from non-www to www. Anything work fine but after redirect I got index file ( app.php ) and i don't know why.
我的htaccess
My htaccess
DirectoryIndex app.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
例如,
如果我输入www.example.com->可以
如果我输入example.com->重定向www.example.com/app.php
For example, If I type www.example.com -> it's ok If I type example.com -> redirect www.example.com/app.php
如何删除app.php?
How Can I remove app.php?
推荐答案
将此内容添加到您的htaccess中
add this in your htaccess
RewriteRule ^app\.php$ http://www.%{HTTP_HOST}/ [R=301,L]
之后
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
这篇关于htcaccess和symfony 2重定向非www->万维网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文