pagination

New to mod_rewrite? This is a good place to start.

pagination

Postby nypd » Mon Jun 07, 2010 5:42 am

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

Code: Select all
#### 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]



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
nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am

Re: pagination

Postby nypd » Mon Jun 07, 2010 11:07 pm

I managed to do it like this:

Code: Select all
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]


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 ?
nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 7 guests

cron