douniewei6346 2016-09-14 06:39
浏览 55

如何在codeigniter中重定向带子域的URL

we have a site which developed in CodeIgniter. And also we have the subdomain.

www.mmm.com
www.admin.mmm.com 

Now we want to redirect URL to the subdomain. ex: mmm.com/result/admin/login : this URL will be open by sub domain (admin.mmm.com) .

How can we do it?

  • 写回答

1条回答 默认 最新

  • dongxin9759 2016-09-14 07:16
    关注

    You are looking for

    redirect($uri = '', $method = 'auto', $code = NULL)
    

    In your case you would do the following in the controller result at the function admin. In that function you should have a code checking if the parameter login is given as the first parameter. Add the following in that piece of code:

    redirect('admin.mmm.com');
    

    Explanation from codeigniter documentation (https://codeigniter.com/userguide3/helpers/url_helper.html#redirect)

    redirect($uri = '', $method = 'auto', $code = NULL)

    Does a “header redirect” to the URI specified. If you specify the full site URL that link will be built, but for local links simply providing the URI segments to the controller you want to direct to will create the link. The function will build the URL based on your config file values.

    The optional second parameter allows you to force a particular redirection method. The available methods are auto, location and refresh, with location being faster but less reliable on IIS servers. The default is auto, which will attempt to intelligently choose the method based on the server environment.

    The optional third parameter allows you to send a specific HTTP Response Code - this could be used for example to create 301 redirects for search engine purposes. The default Response Code is 302. The third parameter is only available with location redirects, and not refresh

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度