伪子域与mod-rewrite [英] Fake Subdomain with mod-rewrite
问题描述
很抱歉问这个问题……我看到了各种各样的答案,但是找不到一个可以帮助我的问题(可能是因为我对这个过程非常陌生)
Sorry to ask this... I have seen various answers on this but I can't find one to help me (prob because I am very new to this process)
这里是问题。我想伪造一个子域,以便人们访问 sub.domain.co.uk
,但服务器将其读取为 domain.co.uk/ ?event = sub
然后他们可以添加其他婴儿车,例如 sub.domain.co.uk/Login
,从而导致域.co.uk /?event = sub& url =登录
等等等
Heres the issue. I want to fake a sub domain so that people go to sub.domain.co.uk
but the server reads it as domain.co.uk/?event=sub
then they can add other prams like sub.domain.co.uk/Login
which leads to domain.co.uk/?event=sub&url=Login
etc etc
我到目前为止的代码是:
The code I have so far is this:
RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif)$
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
# Rewrite event / url / action1 / action 2 etc.
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.co\.uk$ [NC]
RewriteRule ^/$ /index.php?event=%1 [QSA,L,NC]
RewriteRule ^([^/]*)/$ /index.php?event=%1&url=$1 [QSA,L,NC]
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?event=%1&url=$1&action1=$2 [QSA,L,NC]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /index.php?event=%1&url=$1&action1=$2&action2=$3 [QSA,L,NC]
几乎在那里...它的g如果我取消了 /
,则它看起来像这样的 RewriteRule ^ $ index.php ?event =%1 [QSA,L,NC]
然后我得到事件但它试图加载下一个命令,所以
Which is almost there... its getting the url, action1 and action2 but not the event!.. if I take the /
off so it looks like this RewriteRule ^$ index.php?event=%1 [QSA,L,NC]
then I get the event BUT it tried to load the next command so
sub.domain.co.uk
负载
domain.co.uk/?event=sub&url=
这是个虫子,因为当我加载action2时,它在我上面是404!有人帮助它使我发疯了
Which is a bugger because when I load action2 it 404's on me! Someone help its driving me nuts
推荐答案
对,这是我做过的一个糟糕的修复。我的.htaccess现在是这样的:
Right this is a down and dirty fix I have done. my .htaccess is now like this:
# Rewrite event / url / action1 / action 2 etc.
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.co\.uk$ [NC]
RewriteRule ^/$ /index.php [QSA,L,NC]
RewriteRule ^([^/]*)/$ /index.php?url=$1 [QSA,L,NC]
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?url=$1&action1=$2 [QSA,L,NC]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /index.php?url=$1&action1=$2&action2=$3 [QSA,L,NC]
并且在php中,我这样子:
and in the php I have this:
$sub = explode ( '.' , $_SERVER['HTTP_HOST'] );
$event = $sub[0] == 'www' || $sub[0] == 'domain' ? false : $sub[0] ;
现在我可以看看$ event var是否已加载...
Now I can see if the $event var is loaded or not...
如果有人可以用一种更清洁的方式来听我说话,但这对我很有用
If anyone has a cleaner way I am all ears but this is working for me HUZZAR
这篇关于伪子域与mod-rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!