I wrote a regular expression for www.servicesonclick.com/products.php?brandid=27&pname=Acer that redirects to http://www.servicesonclick.com/Acer and
similar to www.servicesonclick.com/products.php?brandid=29&pname=Gigabyte also redirects to http://www.servicesonclick.com/Gigabyte and so on but its not working.. I dont want to retain brandid only retain pname.

Here it is the

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^servicesonclick\.com$ [NC]
RewriteRule ^(.*)$ http://www.servicesonclick.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ products.php?brandid=27&pname=Acer [NC,L,QSA]

Please, I need help..

Use this code in ur htaccess file.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ products.php?brandid=$1&pname=$2 [NC,L,QSA]
</IfModule>

pls chk this link

http://www.servicesonclick.com/Acer

Use this code in ur htaccess file.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ products.php?brandid=$1&pname=$2 [NC,L,QSA]
</IfModule>

pls chk this link

http://www.servicesonclick.com/Acer

Thanks for the Reply, but How I can use brandid and pname. Its not printing pname and brandid..

Use this code in ur htaccess file.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ products.php?brandid=$1&pname=$2 [NC,L,QSA]
</IfModule>

pls chk this link

http://www.servicesonclick.com/Acer

Thanks for the Reply, but How I can use brandid and pname. Its not printing pname and brandid..

You try to get the data using $_REQUEST method in your products.php page.

pls past you products.php code

You try to get the data using $_REQUEST method in your products.php page.

pls past you products.php code

When I echo $_REQUEST on servicesonclick.com/Acer it doesnot shows, but when I echo $_REQUEST on http://www.servicesonclick.com/products.php?brandid=27&pname=Acer it shows.

Here it is the complete code.

<?php
	/////////////////// SECURITY MODULE ////////////////

	function secure_form_data($value){
	$value = htmlentities($value);
	
	if(!is_numeric($value)){ $value = mysql_real_escape_string($value) ; }
	return $value ;}
	
	$link = mysql_connect('localhost', 'gphone', 'mobile123')  or die('Could not connect: ' . mysql_error());
	mysql_select_db('3g') or die("Cann't find database". mysql_error());
	
	/////////////////// END OF SECURITY MODULE /////////


$view="grid";
$phonenames="All Phones";
$criteria="";

$currentpage=1;

$recordsperpage=9;

$listurl="products.php?view=list";
$gridurl="products.php?view=grid";

$sortbyurl="products.php";

$pageurl="products.php";

$selectedorder=0;


@session_start();

if(isset($_GET["page"]))
{
	$currentpage=secure_form_data($_GET["page"]);	
}


if(isset($_GET["sortby"]))
{
	$selectedorder=secure_form_data($_GET["sortby"]);	
}


if(isset($_SESSION["view"]))
{	
	$view=$_SESSION["view"];	
}



if(isset($_GET["view"]))
{
	$view=secure_form_data($_GET["view"]);	

	$_SESSION['view']=secure_form_data($_GET["view"]);
}


if(isset($_GET["brandid"]))
{
	$brandid=secure_form_data($_GET["brandid"]);
	$phonenames=secure_form_data($_GET["pname"])." Phones";
	$criteria="  where brandid=$brandid ";
}
else if(isset($_GET["search_query"]))
{
	
	$keyword = secure_form_data($_GET["search_query"]);

	
	$tokens=split(" ",secure_form_data($_GET["search_query"]));
	
	$phonenames="Search result for ".secure_form_data($_GET["search_query"]);
	foreach($tokens as $k=>$v)
	{
		if($criteria)
		{
			$criteria=$criteria." and ";
		}
		
		//$criteria=$criteria. " (model like '%$v%' or shortdescription  like '%$v%' or description like '%$v%') ";
		$criteria=$criteria. " ((model like '%".strtoupper($v)."%' or model like '%".strtolower($v)."%' or model like '%".ucwords($v)."%') or (shortdescription  like '%".strtoupper($v)."%' or shortdescription  like '%".strtolower($v)."%' or shortdescription  like '%".ucwords($v)."%') or (description like '%".strtoupper($v)."%' or description like '%".strtolower($v)."%' or description like '%".ucwords($v)."%')) ";
		
	}
	$criteria=" where ".$criteria;
	//echo $criteria;
	/*$tokens=explode(" ",$_GET["search_query"]);
	$phonenames="Search result for $_GET[search_query]";
	
	$n = count($tokens);
	for($i=0; $i<$n; $i++) 
	{
		$v=$tokens[$i];
		
		if($criteria)
		{
			$criteria=$criteria." and ";
		}
		$criteria=$criteria. " (model like '%$v%' or shortdescription  like '%$v%' or description like '%$v%' )";
	}
	$criteria=" where ".$criteria;*/
	
}
else if(isset($_GET["feature"]))
{
	$phonenames=secure_form_data($_GET["pname"])." Phones";
	//$criteria=" where phonedetails.$_GET[feature] is not null and length(phonedetails.$_GET[feature])>0";
	if($_GET["feature"]=='Dual SIM')
		$criteria=" where phonedetails.mobile_type = '".secure_form_data($_GET["feature"])."' AND length(phonedetails.$_GET[feature])>0";
	else if($_GET["feature"]=='CDMA')
		$criteria=" where phonedetails.sim_no LIKE '%".secure_form_data($_GET["feature"])."%' AND length(phonedetails.$_GET[feature])>0";
	else
		$criteria=" where (phonedetails.$_GET[feature] != 'No' OR phonedetails.$_GET[feature] != 'no' OR phonedetails.$_GET[feature] != 'NO') AND length(phonedetails.$_GET[feature])>0";
		
}


$surl="";
$purl="";
foreach($_REQUEST as $k=>$v)
{
	if($k!="view")
	{
		$listurl=secure_form_data($listurl) . "&$k=".secure_form_data($v);
		$gridurl=secure_form_data($gridurl) . "&$k=".secure_form_data($v);
	}
	
	if($k!="sortby")
	{
		if($surl)
			$surl=$surl."&";
		else
			$surl=$surl."?";
		
		$surl=$surl."$k=$v";		
	}
	
	if($k!="page")
	{
		if($purl)
			$purl=$purl."&";
		else
			$purl=$purl."?";
		
		$purl=$purl."$k=$v";		
	}
}
$sortbyurl=$sortbyurl.$surl;
$pageurl=$pageurl.$purl;


 include("module_head.php");
 
 
$sortby=array("brand","price: lowest first","price: highest first","editorial reviews: lowest first","editorial first: highest first","user reviews: lowest first","user reviews: highest first");

$orderby=array("brandid, phonedetails.id DESC","price ASC","price DESC","avg_rating ASC","avg_rating DESC","user_rating ASC","user_rating DESC"); 


//echo "<script language=javascript>var surl; surl=$sortbyurl;
?>

<script language="javascript">
var surl="<?php echo secure_form_data($sortbyurl);?>";
	function changeto(sortby)
	{
		var sby=sortby.value;
		if(surl.indexOf("?")>0)
		{
			surl=surl+"&sortby="+sby;
		}
		else
		{
			surl=surl+"?sortby="+sby;
		}
		
		location.href=surl;
		//alert(surl);
	}
</script>
    <p></p>
 <table cellpadding="0" cellspacing="0" width="950px">
<tr>
	<td width="196px" valign="top" style="padding-left:5px">
		<table>
			<tr>
				<td>
					<?php include("module_navigation.php"); ?>
				</td>
			</tr>
			<tr>
				<td>		
					<?php include("module_hot_search.php"); ?>
				</td>
			</tr>
		</table>
	</td>
	
	<td width="634px" valign="top">

	<table width="97%" cellpadding="0" cellspacing="0" style="padding-top:5px">
	<tr>
	<td><?php redtitle($phonenames);?></td>
	<td align="right" valign="middle" style="color:#485C91; font-size:11px ">
	view: 
	<a href="<?php echo $listurl;?>"><img src="images/listview.gif" align="absmiddle" alt="List View" border="0"></a>
	<a href="<?php echo $gridurl; ?>"><img src="images/gridview.gif" align="absmiddle" alt="Grid View" border="0"></a>
	 | Sort By: 
	<select name="sortby" align="absmiddle" onChange="changeto(this);">
	<?php
	
		foreach($sortby as $k=>$v)
		{
			if($k==$selectedorder)
				echo "<option value='$k' selected>$v</option>";
			else
				echo "<option value='$k'>$v</option>";
		}
	?>	
	</select></td></tr>
	</table>
	
	

	<?php
		$phones=mysql_query("select phonedetails.id,model,shortdescription,mrp,price,img1, round((locks+ease+features+value)/4,1) as avg_rating, round(userreviews.rating/count(userreviews.phoneid),1) as user_rating from phonedetails left join userreviews on phonedetails.id=userreviews.phoneid $criteria group by phonedetails.id  order by $orderby[$selectedorder];") or die(mysql_error());		
		if(mysql_num_rows($phones)>0)
		mysql_data_seek($phones,($currentpage-1)*$recordsperpage);
		
			
		
		if(mysql_num_rows($phones)>0)
		{
			mysql_query("insert into hot_search (keyword) values('$keyword')");
		}

		
		if($view=="list")
		{
		
		echo '<table width="97%" cellpadding="5" cellspacing="0" style="border: 1px solid #dddddd; " class="detailsbox">';
		echo "<tr style='background-color: #D2E1E4; font-weight: bold; color: #003366; padding: 2px'><td width='15%'>&nbsp;</td><td width='35%'>Model</td><td width='12%'>Editorial Rating</td><td width='12%'>User Ratings</td><td width='24%'>Price</td></tr>";			
		
			if(mysql_num_rows($phones)<1)
				echo "<tr><td colspan=5> No phone found! </td></tr>";
			else		
			{
				$ct=0;
				while($ct<$recordsperpage && $phone=mysql_fetch_array($phones))
				{
					$bgcolor="#fefefe";
					if($ct%2==0)
						$bgcolor="#f7f7f7";
					$ct++;
					
					echo "<tr bgcolor='$bgcolor'>";
					 phonepics($phone["id"],$phone["model"],1,$phone["img1"],3);					
					
					echo "<td><a href='phone_details.php?id=$phone[id]&model=$phone[id]'><font style='font-size:10pt' class=details_model>$phone[model]</font></a><br><br>$phone[shortdescription]</td>".
					"<td align=center>";
					drawrating($phone["avg_rating"]);
					
					echo "<br>$phone[avg_rating]&nbsp;</td><td align=center>";

					drawrating($phone["user_rating"]);					
				
					echo "<br>$phone[user_rating]&nbsp;</td><td>Mrp: <font class=detailmrp>Rs.$phone[mrp]</font><br><strong>Our Price: <font class=detailprice>Rs. $phone[price]</font></strong>".
					"<br><br><a href='cart.php?addid=$phone[id]'><img src='images/buy_now.gif' border=0></a></td></tr>";

				}				
			}
		
		}
		else
		{		
		//$phones=mysql_query("select id,model,shortdescription,mrp,price,round((locks+features+ease+value)/4,1) as avg_rating,img1 from phonedetails ") or die(mysql_error() ."select id,model,short_description,mrp,price,(locks+features+ease+value)/4 as avg_rating,img1 from phonedetails");
		echo '<table width="97%" cellpadding="0" cellspacing="8" style="border: 1px solid #dddddd; " class="detailsbox">';
		echo "<tr style='height: 180px;' align='center' valign='middle' >";
		$i=1;
		$ct=0;
		while($ct<$recordsperpage && $phone=mysql_fetch_array($phones))
		{
			echo "<td><table class=phonebox cellpadding=0 cellspacing=0 valign=top border=0>".
				"<tr valign=top><td colspan=2 class='phonemodel'>
				<a href='phone_details.php?id=$phone[id]&model=$phone[model]'>
				
				". substr($phone["model"],0,19)."</a></td></tr>".
				"<tr>";			
				 phonepics($phone["id"],$phone["model"],1,$phone["img1"],3);
					

			echo "<td class='description'>". substr($phone["shortdescription"],0,90)."...</font></td></tr>".
				"<tr ><td valign=middle style='padding-left: 4px;'>rating<br>";
				drawrating($phone["avg_rating"]);
				
				
 				echo "<br>$phone[avg_rating]/10</td><td>Mrp: <font class='mrp'>Rs.$phone[mrp]</font><br>".
				"Price: <font class='price'>Rs.$phone[price]</font><br>";

			echo "<a href='cart.php?addid=$phone[id]'><img src=images/buy_now.gif border=0></a>".	
				"</td></tr></table></td>";
						
			if($i%3==0)
				echo "</tr><tr style='height: 180px' align=center valign=middle>";
			
			$i++;
			$ct++;
		}
		}
	?>
	

	</td></tr>
	</table>
	<?php
	$pagedata=$phones;	
	include("module_pagebar.php");
	?>
	
	<br><br>	
	<?php include("module_news.php"); ?>
	<br>

	</td>
	<td width="120px" valign="top" style="padding-right:5px; padding-top:7px;">
	<?php include("module_serachbox.php");?>
	<?php include("module_rightAds.php");?>
	</td>
</tr>
</table>
<?php include("module_footer.php");?>

Please try to get the data using $_REQUEST method instead of $_GET

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.