View Full Version : I Need A Little Help On URL ReWriting!

05-01-2011, 12:20 AM
I am having a little trouble using the Mod rewrite in .htaccess to rewrite my url when I click my paging links. I have included some sample rewrite attempts that I have failed to get working, and a small sample of what some of my paging code looks like. For the life of me, I can't get this to work correctly.

Basically I want: http://www.domain.com/portfolio?page=1

To look like: http://www.domain.com/portfolio/1

My Rewrite Attempt Examples:

RewriteRule ^/([0-9]+)$ /$targetpage?page=$1

RewriteRule ^portfolio/([0-9]+)/$ /targetpage?page=$1 [L]

Small Snippet Of Paging Code Example:

$top_pagination .= "<a class='search_pages' href='$targetpage?page=$counter'>$counter</a>";
$top_pagination .= "<a class='search_pages' href='$targetpage?page=$lpm1'>$lpm1</a>";
$top_pagination .= "<a class='search_pages' href='$targetpage?page=$lastpage'>$lastpage</a>";

$top_pagination .= "<a class='search_pages' href='$targetpage?page=1'>1</a>";
$top_pagination .= "<a class='search_pages' href='$targetpage?page=2'>2</a>";

05-12-2011, 06:05 AM
Your thread got me thinking and this is what I came up with:

RewriteCond %{QUERY_STRING} ^page=(.*)$
RewriteRule http://www.domain.com%{REQUEST_URI}/$1

Please try it and let me know because I'm falling asleep and i'm not sure if it will work or be a complete fail :D

05-12-2011, 08:31 PM
Try this :

rewriterule ^portfolio/(.*)$ targetpage?page=$1