我使用 codeigniter 作为我在主域上的主要安装。我创建了一个子域和一个名为 live 的文件夹,例如live.domain.com 映射到 public/live 。但是在公共(public)场合我使用codeigniter。
我现在有动态 codeigniter url:
http://domain.com/api/
which I want to map to my subdomain:
https://live.domain.com
So going to:
https://live.domain.com/api/functioname
would be using the script:
http://domain.com/api/apifunctioname
and possibly:
http://domain.com/api/apifunctioname/parameter1/parameter
Everything is on the same server so no redirects are needed.
Anyone have any ideas on which rewrite rules to use?
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^live\.domain\.com [NC]
RewriteRule (.+)$ "http://domain.com/api/$1" [L]
上面的代码非常适合重写,但重定向到 http://domain.com/api/functionname相反,我希望它路由;这样当去:
https://live.domain.com/api/functioname
它停留在该网址,但使用的脚本
http://domain.com/api/functionname
非常感谢你,
冰
最佳答案
像下面这样的东西怎么样:
重写引擎开启
RewriteCond %{HTTP_HOST} ^live\.domain\.com$ [NC]
RewriteRule (.+)$ "https://domain.com/api/$1"[L,P]
关于apache - .htaccess 子域的重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/366586/