关于url 重新 rewrite
我的域名是www.123.com 域名已经做了泛解析
网站类是于博客 希望实现用户名.123.com 输入 用户名.123.com 跳转到 index.aspindex.asp 提示 url 地址的用户名 然后跳转至
www.123.com/index.asp?user=用户名现在想实现
www.123.com/index.asp?user=用户名
伪装成
用户名.123.com/
RewriteEngine On
RewriteRule ^http://(.*).123.com$ /index.php?user=$1
这个 不知道 对不对 呵呵~~ 哪位指教一下谢谢~
我的域名是www.123.com 域名已经做了泛解析
网站类是于博客 希望实现用户名.123.com 输入 用户名.123.com 跳转到 index.aspindex.asp 提示 url 地址的用户名 然后跳转至
www.123.com/index.asp?user=用户名现在想实现
www.123.com/index.asp?user=用户名
伪装成
用户名.123.com/
RewriteEngine On
RewriteRule ^http://(.*).123.com$ /index.php?user=$1
这个 不知道 对不对 呵呵~~ 哪位指教一下谢谢~
希望能和你多讨论下
这是我的配置
<VirtualHost *:8082>
ServerAdmin [email protected]
DocumentRoot E:/web/htdocs
ServerName blog.com
ServerAlias *.blog.com
ErrorLog logs/all-sites-error_log
CustomLog logs/all-sites-access_log common RewriteEngine on
#RewriteConf %{HTTP_HOST} ^([a-z][a-z][0-9])\.blog\.com$
#RewriteRule /(.*) yu4/$1 [L] RewriteCond %{HTTP_HOST} ^([a-z]*[0-9])\.blog\.com:8082$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([a-z][a-z][0-9])\.blog\.com:8082/$ /$1 [L]
<Directory />
我的目的是希望输入用户名/blog/com:8082 跳到 用户名/blog/com:8082/用户名 下
比如 http://yu/blog/com:8082 跳到http://yu/blog/com:8082/yu 就可以了
却怎么也成功不了 期待你的交流
你的问题 老衲认为 你把域名泛解析了
然后指向主页就行了 主页根据url地址 在跳转
在把*指向主机然后在主机的主页中 加一段程序吧
提取url地址 然后取出前缀
然后跳转到WWW.XXX.COM/INDEX.ASP?USER=用户名老衲的想法
公司里准备做blog系统。要我先在自己机子上搞下二级域名解析。
比如说输入http://yu4.blog.com (yu4是用户名)就能直接进入用户的目录下。
我的目录是这样设定的:(httpd.conf文件中修改)
DocumentRoot E:\web\htdocs
这个目录下有yu1,yu2,yu3,yu4等子目录 (就是代表各个用户)然后我在C:\WINDOWS\system32\drivers\etc hosts文件中加入
192.168.22.46 yu4.blog.com
这样我输入http://yu4.blog.com:8082 (我将apache的80端口改成8082的了)才能进入apache设置的DocumentRoot 也就是E:\web\htdocs下的index.html文件然后我需要的是输入http://yu4.blog.com:8082能够进入到E:\web\htdocs\yu4目录中
也就用到重写规则 在hpptd-vhost.conf文件中加上:
<VirtualHost *:8082>
ServerAdmin [email protected]
DocumentRoot E:/webdocs
ServerName blog.com
ServerAlias *.blog.com
ErrorLog logs/all-sites-error_log
CustomLog logs/all-sites-access_log common
RewriteEngine on RewriteCond %{HTTP_HOST} ^([a-z][a-z][0-9])\.blog\.com:8082$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([a-z][a-z][0-9])\.blog\.com:8082/$ /$1 [L]
<Directory />
Options Indexes FollowSymLinks
AllowOverride all
</Directory>
</VirtualHost>
可是怎么也不能成功哦 最关键的一点是要求动态的 也就是说输入http://yu5.blog.com:8082能进入yu5目录下,输入http://yu6.blog.com能进入yu6下 ...而且不涉及到DNS系统 就是一个人在apache上做测试 看这个效果能不能达到我的想法是 把http://yu4.blog.com:8082变成
http://yu4.blog.com:8082/yu4 而地址栏上变不变化都无所谓
谢谢指教
二是泛解析重写
重写没有多少问题!你可能也实现了!
如果你能重写成功,这个也不存问题!第三个是.htaccess实现不了这个功能
第四如果有httpd权限,重写应是不成问题
第五个,伪装成用户名.123.com/ ,如果上面的不成,就要用到内部代理模块手册有小段专门说这个
http://www.zzxj.net/web/manual/ApacheMenu/rewrite/rewrite_guide.html
top
虚拟用户主机描述:
如果需要为用户username支持一个www.username.host.domain.com的主页,但不在此机器上建虚拟主机,而是仅用在此机器上增加一个DNS A记录的方法实现。
解决方案:
仅能对包含"Host: "头的HTTP/1.1请求实现。可以使用以下规则集内部地将http://www.username.host.com/anypath重写为/home/username/anypath RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.host\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.host\.com(.*) /home/$1$2
/*----------------------------------三级域名控制开始 ------------------------------------------*/
if($menu == "")
{
$url=$_SERVER["HTTP_HOST"];
//echo $url;www.ceiea.com -----------a.co.ceiea.com
$a = explode(".",$url);
$b = count($a);
if($b==4)//3级域名
{
if($a[1]=="shop")//企业3级域名
{
$sqltid = "select id,third_name,third_end,prook,co_end,typeid from equip_company where third_name='".$a[0]."'";
$rttid = $DB->Query($sqltid);
$numtid = $DB->getRowsNum($rttid);
$rstid = $DB->getRows($rttid);
if($numtid==1)//申请了3级域名
{
//申请了还得看他是不是有3级域名的权限
if($rstid[0]["third_end"]>date('Y-m-d'))//单独开通的
{
$c = "http://www.ceiea.com/coindex/index.php?id=".$rstid[0]["id"];
$d = file_get_contents($c);
echo $d;
}
else//没有单独开通,看企业类别了
{
$sqla="select id,third_domain from allset where id=1";
$rta = $DB->Query($sqla);
$rsa = $DB->getRows($rta);
$qxa = $rsa[0]["third_domain"];
$qx = explode("|",$qxa);//0|0|1|1
if($rstid[0]["co_end"]>date('Y-m-d') && $rstid[0]["typeid"]>71)//是收费会员
{
switch((int)$rstid[0]["typeid"])
{
case 115://初级
if((int)$qx[1]==1 && strlen($rstid[0]["third_name"]."f")>1)
{
$c = "http://www.ceiea.com/coindex/index.php?id=".$rstid[0]["id"];
$d = file_get_contents($c);
echo $d;
}
else
{
$c = "http://www.ceiea.com/index.shtml";
$d = file_get_contents($c);
echo $d;
}
break;
case 72://中级
if((int)$qx[2]==1 && strlen($rstid[0]["third_name"]."f")>1)
{
$c = "http://www.ceiea.com/coindex/index.php?id=".$rstid[0]["id"];
$d = file_get_contents($c);
echo $d;
}
else
{
$c = "http://www.ceiea.com/index.shtml";
$d = file_get_contents($c);
echo $d;
}
break;
case 73://高级
if((int)$qx[3]==1 && strlen($rstid[0]["third_name"]."f")>1)
{
$c = "http://www.ceiea.com/coindex/index.php?id=".$rstid[0]["id"];
$d = file_get_contents($c);
echo $d;
}
else
{
$c = "http://www.ceiea.com/index.shtml";
$d = file_get_contents($c);
echo $d;
}
break;
}
}
else//是免费会员
{
if((int)$qx[0]==1 && strlen($rstid[0]["third_name"]."f")>1)
{
$c = "http://www.ceiea.com/coindex/index.php?id=".$rstid[0]["id"];
$d = file_get_contents($c);
echo $d;
}
else
{
$c = "http://www.ceiea.com/index.shtml";
$d = file_get_contents($c);
echo $d;
}
}
}
}
else//没有申请3级域名,或者没有被开通
{
$c = "http://www.ceiea.com/index.shtml";
$d = file_get_contents($c);
echo $d;
}
}
else//不是企业3级域名,可以扩展为其他三级域名
{
$c = "http://www.ceiea.com/index.shtml";
$d = file_get_contents($c);
echo $d;
}
}
else
{
$c = "http://www.ceiea.com/index.shtml";
$d = file_get_contents($c);
echo $d;
}
}