【问题标题】:php - One domain to each user account url in CodeIgniterphp - CodeIgniter 中每个用户帐户 url 的一个域
【发布时间】:2013-01-04 17:54:40
【问题描述】:

我正在为自己的婚礼开发一个婚礼网站,我有一些朋友想要使用它。

我只是在域之后匹配用户名的模式,如下所示:

http://example.com/username => route to controler/index/username

http://example.com/username2 => route to controler/index/username2

等等……

现在我想这样做:

www.username.com => route to controler/index/username

www.username2.com => route to controler/index/username2

但我想同时持有这两种方法。

【问题讨论】:

    标签: php codeigniter url


    【解决方案1】:

    您无法在 CI 中解决此问题。它需要使用 apaches 域重写,因为这将格式化正确的重定向

    <VirtualHost *>
      ServerName www.example.com
      Redirect 301 / http://example.com/username
    </VirtualHost>
    

    【讨论】:

      【解决方案2】:

      你可以使用

         <meta http-equiv="refresh" content="1;url=<?php echo $adr; ?>">
      

      并使用$_SERVER 获取当前地址。 (例如“用户名”并重定向到http://www.username.com。)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-03
        • 1970-01-01
        • 2010-12-01
        • 1970-01-01
        • 2012-09-06
        相关资源
        最近更新 更多