Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-30-2011, 11:20 PM   PM User | #1
designer76
New Coder

 
Join Date: Aug 2009
Posts: 45
Thanks: 20
Thanked 0 Times in 0 Posts
designer76 is an unknown quantity at this point
I Need A Little Help On URL ReWriting!

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:

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

RewriteRule ^portfolio/([0-9]+)/$ /targetpage?page=$1 [L]
Small Snippet Of Paging Code Example:

Code:
$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>";		
}

else
{
$top_pagination .= "<a class='search_pages' href='$targetpage?page=1'>1</a>";
$top_pagination .= "<a class='search_pages' href='$targetpage?page=2'>2</a>";
designer76 is offline   Reply With Quote
Old 05-12-2011, 05:05 AM   PM User | #2
m4rc3
New to the CF scene

 
Join Date: May 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
m4rc3 is an unknown quantity at this point
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
m4rc3 is offline   Reply With Quote
Old 05-12-2011, 07:31 PM   PM User | #3
Mayhem30
New Coder

 
Join Date: Jan 2010
Posts: 63
Thanks: 2
Thanked 5 Times in 4 Posts
Mayhem30 is an unknown quantity at this point
Try this :

Code:
rewriterule ^portfolio/(.*)$ targetpage?page=$1
Mayhem30 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:19 PM.


Advertisement
Log in to turn off these ads.