htaccess的重写规则的子域名 [英] .htaccess Rewrite Rules for subdomain

查看:190
本文介绍了htaccess的重写规则的子域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用codeigniter作为我的主要安装在主域名。我创建了一个子域和一个文件夹,名为活例如: live.domain.com映射到公/直播。然而,在公共我使用codeigniter。

I use codeigniter as my main install on the main domain. I have created a subdomain and a folder called live e.g. live.domain.com maps to public/live . However in public I use codeigniter.

我现在有动态codeigniter网址:

I now have the dynamic codeigniter url:

http://domain.com/api/

这是我想要映射到我的子域:

which I want to map to my subdomain:

https://live.domain.com

于是打算:

https://live.domain.com/api/functioname

将使用脚本:

would be using the script:

http://domain.com/api/apifunctioname

和可能的:

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 ,而不是我想要的路由;这样当进入:

The above works great as a rewrite but redirects to http://domain.com/api/functionname instead I want it to route; so that when going to:

https://live.domain.com/api/functioname

它停留在此网址,但使用的脚本

It stays at that url but uses the script of

http://domain.com/api/functionname

非常感谢你,

Thank you very much,

推荐答案

如何类似如下:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^live\.domain\.com$ [NC]
RewriteRule (.+)$ "https://domain.com/api/$1" [L,P]

这篇关于htaccess的重写规则的子域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆