.htaccess pagination

Discussion in 'Apache' started by bedio, Jun 8, 2010.

  1. #1
    I have the following code, which rewrites and redirects from this:
    http://domain.com/photo/thumbnails.php?album=search&type=full&search=wallpapers

    to this:
    http://domain.com/photo/wallpapers.htm

    #### PHOTO SEARCH RESULTS REWRITES
    
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{QUERY_STRING} ^(.*&)?album=search(&.*)?$ [NC]
    RewriteCond %{QUERY_STRING} ^(.*&)?search=([^&]+)(&.*)?$ [NC]
    
    RewriteRule ^(wraps/)?photo/thumbnails\.php$ /photo/%2.htm? [R=301,L]
    
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
    RewriteRule ^photo/(.+)\.htm$ /wraps/photo/thumbnails.php?album=search&search=$1 [QSA,L]
    Code (markup):

    That is good, but how to create pagination as well from this:
    http://domain.com/photo/thumbnails.php?album=search&type=full&search=wallpapers&page=3

    to this:
    http://domain.com/photo/wallpapers.htm/3

    EDIT:


    I managed to do it like this:

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{QUERY_STRING} ^(.*&)?album=search(&.*)?$ [NC]
    RewriteCond %{QUERY_STRING} ^(.*&)?search=([^&]+)(&.*)?$ [NC]
    RewriteCond %{QUERY_STRING} ^(.*&)?page=([^&]+)(&.*)?$ [NC]
    
    RewriteRule ^(wraps/)?photo/thumbnails\.php$ /photo/%2.htm/%3? [R=301,L]
    
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
    RewriteRule ^photo/(.+)\.htm/(.+)$ /wraps/photo/thumbnails.php?album=search&search=$1&page=$2 [QSA,L]
    Code (markup):
    however as my base dir is /photo/ now it is /photo/search_word.htm, and that makes all images to be load in the page with this URL /photo/search_word.htm/albulms/1001/alanis.jpg instead of /photo/albulms/1001/alanis.jpg

    How do I make this search_word.htm/ invisible to the site content. How I make photo to be root for the site ?
     
    bedio, Jun 8, 2010 IP