htaccess的"伪造子域" [英] htaccess "faking subdomains"

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

问题描述

我一直在寻找htaccess以及如何使用重写规则,以便使一种假子域的用户。

I've been looking at htaccess and how to use rewrite rules in order to make a sort of "fake subdomain" for users.

到目前为止,我有:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([a-z0-9-]+)/? http://$1.domain.com [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^([a-z]+)\.domain\.com$
RewriteRule ^$ index.php?user=%1

这将采取任何/财产以后,并使其成为一个子域,然后通过子域值作为参数来接了。

this will take any /somthing and make it a subdomain and then pass the subdomain value in as a param to pick up.

我希望能够到现在使用实际参数,并通过normaly从子域额外的用户参数将它们传递 例如,

i want to be able to now use actual parameters, and pass them through normaly with the extra "user" param from the "subdomain" e.g.

fred.domain.com/index.php?page=1&sort=up

会给我在$ _GET

would give me in $_GET

['user'] = 'fred'
['page']= 1
['sort'] = up

但对我的生活中,我无法弄清楚如何做到这一点!因为当我添加任何其他参数,可以让我松了用户比特

but for the life of me I cant figure out how to do this! as when i add any other params, I loose the user bit

任何帮助吗? =)

同样在htaccess的任何有用的教程将是很好!因为所有的人香港专业教育学院发现还没有真正解释了什么是每一位做,为什么= \

Also any helpful tutorials on htaccess would be nice! as all ones ive found haven't really explained what each bit does and why =\

在此先感谢

推荐答案

我是pretty的肯定,你可以设置虚拟主机* .yourdomain.com指向一个路径,然后使用mod_rewrite的URL解析。

I'm pretty sure you can set vhost *.yourdomain.com to point to a single path and then use mod_rewrite for the url parsing.

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

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