1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

rewite page url and cat

Discussion in 'Apache' started by frostherrien, Nov 27, 2007.

  1. #1
    Im a real newbies in rewite rules....

    In my htaccess
    RewriteEngine on

    #Redirect http://site.com to http://www.agentsexe.com
    RewriteCond %{HTTP_HOST} ^site.com
    RewriteRule ^(.*)$ http://www.site.com/$1 [r=301,L]
    RewriteRule ^page([0-9]+)\.html*$ /index.php?page=$1 [L]

    desired url: www.site.com/page-1.html
    and for my 3 different Categories
    desired url: www.site.com/page-1-humor.html
    desired url: www.site.com/page-1-trash.html
    desired url: www.site.com/page-1-sexy.html

    This is my code index.php:
    if($page>0)
    {
    	$j=$page-1;
    	$url="?page=$j";
    	$pageshtml.="<a href=\"$url&cat=$cat\"><<</a>";
    }
    
    for($i=0;$i<$pages;$i++)
    {
    	$url="?page=".$i;
    	$j=$i+1;
    	if($_GET[page]==$i){$pageshtml.=" <b>$j</b> ";}else{$pageshtml.=" <a href=\"$url&cat=$cat\">$j</a> ";}
    }
    
    if($page<$pages-1)
    {
    	$j=$page+1;
    	$url="?page=$j";
    	$pageshtml.="<a href=\"$url&cat=$cat\">>></a>";
    }
    $pageshtml.="</center>";
    
    PHP:
    this code show a defaut link:
    http://www.site.com/?page=1&cat=
    http://www.site.com/?page=1&cat=funny

    can i use this variable :
    $newouturl = str_replace(" ", "-", $row[title]);
    $gallery=str_replace("%outurl%","http://www.site.com/$row[id]-$newouturl.html",$gallery);
     
    frostherrien, Nov 27, 2007 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    powerspike, Nov 27, 2007 IP
  3. frostherrien

    frostherrien Active Member

    Messages:
    161
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #3
    i try it but that don't work.. i think is the php code make some conflic...
     
    frostherrien, Nov 28, 2007 IP
  4. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    RewriteRule ^page-([0-9]+)-([a-zA-Z0-9]+).html http://www.site.com/index.php?page=$1&cat=$2 [NC,L]



    try that, it might not of liked the scriptname not been there.
     
    powerspike, Nov 28, 2007 IP