Note that there are some explanatory texts on larger screens.

plurals
  1. POAdjusting a php function so that it displays link in the form of:- '/widgets?pg=2' instead of 'products.php?cat=20&pg=2'
    primarykey
    data
    text
    <p>I added the following .htaccess rule:- </p> <pre><code>RewriteRule ^widgets$ products.php?cat=20 [QSA] </code></pre> <p>So now I have a simple link called 'widgets' which leads to the 'widgets' category 1st page. However, the links to the 2nd page looks like the following:-</p> <pre><code>products.php?cat=20&amp;pg=2 </code></pre> <p>What I would like is for the subsequent pages to be rather in the form of:-</p> <pre><code>widgets?pg=2 </code></pre> <p>The QSA flag in the above .htaccess rule does achieve this, but I need to change the function which generates these page links, otherwise the only way of getting to <code>widgets?pg=2</code> is by typing it in the browser address bar as:- <code>mywebsite.com/widgets?pg=2</code>.</p> <p>I think the following PHP function might need to be adjusted, to achieve the result I want. Can any PHP wizards or anyone with appropriate knowledge please help with this. The reason I want to do this is because I want google to index the simple looking pages, rather than the longer ones:-</p> <pre><code>function writepagebar($CurPage,$iNumPages,$sprev,$snext,$sLink,$nofirstpage){ $startPage = max(1,round(floor((double)$CurPage/10.0)*10)); $endPage = min($iNumPages,round(floor((double)$CurPage/10.0)*10)+10); if($CurPage &gt; 1) $sStr = $sLink . '1' . '" rel="prev"&gt;&lt;span style="font-family:Verdana;font-weight:bold"&gt;&amp;laquo;&lt;/span&gt;&lt;/a&gt; ' . $sLink . ($CurPage-1) . '"&gt;'.$sprev.'&lt;/a&gt; | '; else $sStr = '&lt;span style="font-family:Verdana;font-weight:bold"&gt;&amp;laquo;&lt;/span&gt; '.$sprev.' | '; for($i=$startPage;$i &lt;= $endPage; $i++){ if($i==$CurPage) $sStr .= '&lt;span class="currpage"&gt;' . $i . '&lt;/span&gt; | '; else{ $sStr .= $sLink . $i . '"&gt;'; if($i==$startPage &amp;&amp; $i &gt; 1) $sStr .= '...'; $sStr .= $i; if($i==$endPage &amp;&amp; $i &lt; $iNumPages) $sStr .= '...'; $sStr .= '&lt;/a&gt; | '; } } if($CurPage &lt; $iNumPages) $sStr .= $sLink . ($CurPage+1) . '" rel="next"&gt;'.$snext.'&lt;/a&gt; ' . $sLink . $iNumPages . '"&gt;&lt;span style="font-family:Verdana;font-weight:bold"&gt;&amp;raquo;&lt;/span&gt;&lt;/a&gt;'; else $sStr .= ' '.$snext.' &lt;span style="font-family:Verdana;font-weight:bold"&gt;&amp;raquo;&lt;/span&gt;'; if($nofirstpage) $sStr = str_replace(array('&amp;amp;pg=1"','?pg=1"'),'" rel="start"',$sStr); return($sStr); } </code></pre> <p>If it helps to know how the writepagebar function fits into the incproducts.php which itself sits inside the products.php page you can see here:- </p> <p><a href="http://freetexthost.com/3ubiydspzm" rel="nofollow noreferrer">http://freetexthost.com/3ubiydspzm</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload