在URL使用htaccess的删除子文件夹名称 [英] remove subfolder name in url using htaccess
本文介绍了在URL使用htaccess的删除子文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网站,并使用htaccess的code的重定向,在那,我有URL如http://username.domainname.com/userid
并希望删除部分用户ID,这样一来,该网址看起来像http://username.domainname.com/
。
i have an site and using the htaccess code for redirections, in that, i have url like "http://username.domainname.com/userid"
and want to remove the part "userid", so that, the url will look like "http://username.domainname.com/"
.
我用下面的code获得http://username.domainname.com/userid
:
i use the following code to get "http://username.domainname.com/userid"
:
RewriteEngine on
RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+)$ /user_detail.php?cId=$1 [NC,L]
在此先感谢帮助我。
推荐答案
我写了一组code在PHP页面,这是精细的工作。在索引页,包括以下code:
i wrote a set of code in php page, which is finely working. in index page, include the following code :
$cId=0;
$url=$_SERVER['HTTP_HOST'];
$a= explode(".",$url);
$objComp = new mysql_profile();
$arrOrg= $objComp->select_admin_profileorgs(0);
if($a[1]!='bgrow')
{
if(count($arrOrg) > 0)
{
for($i=0;$i<count($arrOrg);$i++){
$cUrl = $arrOrg[$i]['cUrl'];
if((strtolower($cUrl) == $a[0]) || (strtolower($cUrl) == $a[1])) {
include($PATH."domain.com/user_detail.php");
}
}
}
}
else { // inderpage content }
这篇关于在URL使用htaccess的删除子文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文