很抱歉问这个..。我已经看到了关于这个问题的各种答案,但我找不到一个来帮助我(可能是因为我对这个过程非常陌生)
这是问题所在。我想伪造一个子域,这样人们就可以转到sub.domain.co.uk,但服务器将其读取为domain.co.uk/?event=sub,然后他们可以添加其他prams,如sub.domain.co.uk/Login,这将导致domain.co.uk/?event=sub&url=Login等
到目前为止,我拥有的代码是:
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]就快到了..。它得到了url、action1和action2,但没有得到事件!如果我将/去掉,使它看起来像这样的RewriteRule ^$ index.php?event=%1 [QSA,L,NC],那么我会得到一个事件,但它试图加载下一个命令
sub.domain.co.uk负载
domain.co.uk/?event=sub&url=这是一个虫子,因为当我加载action2时,它的404在我身上!谁来帮帮忙我都快疯了
发布于 2013-03-02 21:13:40
对,这是我做的一个糟糕的修复。我的.htaccess现在是这样的:
# 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中我有这样的代码:
$sub = explode ( '.' , $_SERVER['HTTP_HOST'] );
$event = $sub[0] == 'www' || $sub[0] == 'domain' ? false : $sub[0] ;现在我可以查看是否加载了$event变量...
如果有人有更干净的方法,我洗耳恭听,但这对我很管用,哈扎。
https://stackoverflow.com/questions/15168154
复制相似问题