Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    45
    Thanks
    20
    Thanked 0 Times in 0 Posts

    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>";

  • #2
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Jan 2010
    Posts
    68
    Thanks
    3
    Thanked 5 Times in 4 Posts
    Try this :

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •