doufei3152 2014-02-14 05:48
浏览 19
已采纳

当public_html和www相同时,如何使用PHP代码进行301重定向

I actually have PHP code for making 301 redirect on my site.Previously i done this by putting that PHP code on \public_html\site_name\index.php and that is not the same in www\site_name\index

(\public_html and \www are not same at that time).

But now these two folders(public_html and www) are showing the same content.Then now where i need to put the code?how to achieve 301 redirect using PHP when the *\public_html* and \www folders are in same.

  • 写回答

2条回答 默认 最新

  • dongxie5698 2014-02-14 07:01
    关注

    Give this a try, put this in your htaccess in the root of your site.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com$
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    

    replace example.com with your domain.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度