RewriteEngine On
# Category links
RewriteRule ^cat-([0-9]+)-page-([0-9]+)\.php index.php?cat=$1&page=$2 [NC]
RewriteRule ^cat-([0-9]+)\.php index.php?cat=$1 [NC]

# Slideshow
RewriteRule ^slideshow-album-([a-z0-9]*)-cat-([0-9]+)-user-([0-9]+)-pid-([0-9]+)-delay-([0-9]+)\.php displayimage.php?album=$1&cat=$2&uid=$3&pid=$4&slideshow=$5 [NC]
RewriteRule ^slideshow-album-([a-z0-9]*)-cat-([0-9]+)-pid-([0-9]+)-delay-([0-9]+)\.php displayimage.php?album=$1&cat=$2&pid=$3&slideshow=$4 [NC]
RewriteRule ^slideshow-album-([a-z0-9]*)-pid-([0-9]+)-delay-([0-9]+)\.php displayimage.php?album=$1&pid=$2&slideshow=$3 [NC]

# Thumbnail random files
RewriteRule ^random-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=random&cat=$1&pos=-$2 [NC]
RewriteRule ^random-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=random&cat=-$1&pos=-$2 [NC]
RewriteRule ^random-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=random&cat=-$1&pos=-$2 [NC]

# Thumbnail last additions
RewriteRule ^last-uploads-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastup&cat=$1&pos=$2 [NC]
RewriteRule ^last-uploads-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastup&cat=-$1&pos=$2 [NC]
RewriteRule ^last-uploads-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastup&cat=-$1&pos=$2 [NC]

# Thumbnail most viewed
RewriteRule ^most-viewed-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=topn&cat=$1&pos=$2 [NC]
RewriteRule ^most-viewed-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=topn&cat=-$1&pos=$2 [NC]
RewriteRule ^most-viewed-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=topn&cat=-$1&pos=$2 [NC]

# Thumbnail top rated
RewriteRule ^top-rated-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=toprated&cat=$1&pos=$2 [NC]
RewriteRule ^top-rated-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=toprated&cat=-$1&pos=$2 [NC]
RewriteRule ^top-rated-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=toprated&cat=-$1&pos=$2 [NC]

# Thumbnail last comments
RewriteRule ^last-comments-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastcom&cat=$1&pos=$2 [NC]
RewriteRule ^last-comments-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastcom&cat=-$1&pos=$2 [NC]
RewriteRule ^last-comments-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastcom&cat=-$1&pos=$2 [NC]

# Thumbnail last viewed
RewriteRule ^last-viewed-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lasthits&cat=$1&pos=$2 [NC]
RewriteRule ^last-viewed-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lasthits&cat=-$1&pos=$2 [NC]
RewriteRule ^last-viewed-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lasthits&cat=-$1&pos=$2 [NC]

# Last uploads
RewriteRule ^last-uploads-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastup&cat=$1&page=$2 [NC]
RewriteRule ^last-uploads-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastup&cat=-$1&page=$2 [NC]
RewriteRule ^last-uploads-cat-([0-9]+)\.php thumbnails.php?album=lastup&cat=$1 [NC]
RewriteRule ^last-uploads-album-([0-9]+)\.php thumbnails.php?album=lastup&cat=-$1 [NC]
RewriteRule ^last-uploads\.php thumbnails.php?album=lastup [NC]

# Most viewed
RewriteRule ^most-viewed-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=topn&cat=$1&page=$2 [NC]
RewriteRule ^most-viewed-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=topn&cat=-$1&page=$2 [NC]
RewriteRule ^most-viewed-cat-([0-9]+)\.php thumbnails.php?album=topn&cat=$1 [NC]
RewriteRule ^most-viewed-album-([0-9]+)\.php thumbnails.php?album=topn&cat=-$1 [NC]
RewriteRule ^most-viewed\.php thumbnails.php?album=topn [NC]

# Top rated
RewriteRule ^top-rated-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=toprated&cat=$1&page=$2 [NC]
RewriteRule ^top-rated-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=toprated&cat=-$1&page=$2 [NC]
RewriteRule ^top-rated-cat-([0-9]+)\.php thumbnails.php?album=toprated&cat=$1 [NC]
RewriteRule ^top-rated-album-([0-9]+)\.php thumbnails.php?album=toprated&cat=-$1 [NC]
RewriteRule ^top-rated\.php thumbnails.php?album=toprated [NC]

# Last comments
RewriteRule ^last-comments-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastcom&cat=$1&page=$2 [NC]
RewriteRule ^last-comments-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastcom&cat=-$1&page=$2 [NC]
RewriteRule ^last-comments-cat-([0-9]+)\.php thumbnails.php?album=lastcom&cat=$1 [NC]
RewriteRule ^last-comments-album-([0-9]+)\.php thumbnails.php?album=lastcom&cat=-$1 [NC]
RewriteRule ^last-comments\.php thumbnails.php?album=lastcom [NC]

# Last viewed
RewriteRule ^last-viewed-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lasthits&cat=$1&page=$2 [NC]
RewriteRule ^last-viewed-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lasthits&cat=-$1&page=$2 [NC]
RewriteRule ^last-viewed-cat-([0-9]+)\.php thumbnails.php?album=lasthits&cat=$1 [NC]
RewriteRule ^last-viewed-album-([0-9]+)\.php thumbnails.php?album=lasthits&cat=-$1 [NC]
RewriteRule ^last-viewed\.php thumbnails.php?album=lasthits [NC]

# My Favorites
RewriteRule ^my-favorite-pictures\.php thumbnails.php?album=favpics [NC]

# Album links with pages and sort
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-title-ascending\.php thumbnails.php?album=$1&page=$2&sort=ta [NC]
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-title-descending\.php thumbnails.php?album=$1&page=$2&sort=td [NC]
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-name-ascending\.php thumbnails.php?album=$1&page=$2&sort=na [NC]
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-name-descending\.php thumbnails.php?album=$1&page=$2&sort=nd [NC]
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-date-ascending\.php thumbnails.php?album=$1&page=$2&sort=da [NC]
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-date-descending\.php thumbnails.php?album=$1&page=$2&sort=dd [NC]
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-position-ascending\.php thumbnails.php?album=$1&page=$2&sort=pa [NC]
RewriteRule ^album-([0-9]+)-page-([0-9]+)-sort-position-descending\.php thumbnails.php?album=$1&page=$2&sort=pd [NC]

# Album links
RewriteRule ^album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=$1&page=$2 [NC]
RewriteRule ^album-([0-9]+)\.php thumbnails.php?album=$1 [NC]

# Profile links
RewriteRule ^user-([0-9]+)\.php  profile.php?uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-uploads-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastupby&cat=$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-uploads-catn-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastupby&cat=-$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-uploads-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastupby&cat=-$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-uploads-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastupby&cat=$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-uploads-catn-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastupby&cat=-$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-uploads-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastupby&cat=-$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-uploaded\.php  thumbnails.php?album=lastupby&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-uploaded-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastupby&cat=$2&pos=$3&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-uploaded-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastupby&cat=-$2&pos=$3&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-uploaded-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastupby&cat=-$2&pos=$3&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-comments-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastcomby&cat=$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-comments-catn-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastcomby&cat=-$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-comments-album-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=lastcomby&cat=-$2&uid=$1&page=$3 [NC]
RewriteRule ^user-([0-9]+)-last-comments-cat-([0-9]+)\.php thumbnails.php?album=lastcomby&cat=$2&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-comments-catn-([0-9]+)\.php thumbnails.php?album=lastcomby&cat=-$2&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-comments-album-([0-9]+)\.php thumbnails.php?album=lastcomby&cat=-$2&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-comment\.php  thumbnails.php?album=lastcomby&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-comment-pics-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastcomby&cat=$2&pos=$3&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-comment-pics-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastcomby&cat=-$2&pos=$3&uid=$1 [NC]
RewriteRule ^user-([0-9]+)-last-comment-pics-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=lastcomby&cat=-$2&pos=$3&uid=$1 [NC]
RewriteRule ^my-profile\.php  profile.php?op=edit_profile [NC]

# Display image link
RewriteRule ^display-image-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=$1&pos=$2 [NC]

# Image direct link
RewriteRule ^picture-([0-9]+)\.php displayimage.php?pos=-$1 [NC]

# Picture rate link
RewriteRule ^rate-image-([0-9]+)-rate-([0-9]+)\.php ratepic.php?pic=$1&rate=$2 [NC]

# Report picture link
RewriteRule ^report-image-album-([0-9]+)-pic-([0-9]+)-pos-([0-9]+)\.php report_file.php?album=$1&pid=$2&pos=$3 [NC]
RewriteRule ^report-image-album-([a-z]+)-cat-([0-9]+)-pic-([0-9]+)-pos-([0-9]+)\.php report_file.php?album=$1&cat=$2&pid=$3&pos=$4 [NC]
RewriteRule ^report-image-album-([a-z]+)-catn-([0-9]+)-pic-([0-9]+)-pos-([0-9]+)\.php report_file.php?album=$1&cat=-$2&pid=$3&pos=$4 [NC]
RewriteRule ^report-comment-pid-([0-9]+)-msgid-([0-9]+)\.php report_file.php?pid=$1&msg_id=$2&what=comment [NC]

# E-Card picture link
RewriteRule ^ecard-image-album-([0-9]+)-pic-([0-9]+)-pos-([0-9]+)\.php ecard.php?album=$1&pid=$2&pos=$3 [NC]
RewriteRule ^ecard-image-album-([a-z]+)-cat-([0-9]+)-pic-([0-9]+)-pos-([0-9]+)\.php ecard.php?album=$1&cat=$2&pid=$3&pos=$4 [NC]
RewriteRule ^ecard-image-album-([a-z]+)-catn-([0-9]+)-pic-([0-9]+)-pos-([0-9]+)\.php ecard.php?album=$1&cat=-$2&pid=$3&pos=$4 [NC]

# Index urls
RewriteRule ^index\.htm index.php [NC]
RewriteRule ^index\.php index.php [NC]

# FAQ
RewriteRule ^faq\.php faq.php [NC]

# Register
RewriteRule ^register\.php register.php [NC]

# Login/Logout
RewriteRule ^login\.php login.php [NC]
RewriteRule ^logout\.php logout.php [NC]

# Upload
RewriteRule ^upload\.php upload.php [NC]

# Search links
RewriteRule ^search\.php search.php [NC]
RewriteRule ^search-([a-z0-9]*)\.php thumbnails.php?album=search&search=$1 [NC]
RewriteRule ^search-cat-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=search&cat=$1&page=$2 [NC]
RewriteRule ^search-catn-([0-9]+)-page-([0-9]+)\.php thumbnails.php?album=search&cat=-$1&page=$2 [NC]
RewriteRule ^display-search-image-cat-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=search&cat=$1&pos=$2 [NC]
RewriteRule ^display-search-image-catn-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=search&cat=-$1&pos=$2 [NC]
RewriteRule ^display-search-image-album-([0-9]+)-pos-([0-9]+)\.php displayimage.php?album=search&cat=-$1&pos=$2 [NC]

# Users
RewriteRule ^users\.php usermgr.php [NC]

# Forgot Password
RewriteRule ^forgot-password\.php forgot_passwd.php [NC]

# Album management
RewriteRule ^album-manager\.php albmgr.php [NC]
RewriteRule ^modify-album-([0-9]+)\.php modifyalb.php?album=$1 [NC]
RewriteRule ^modify-album\.php modifyalb.php [NC]

# Picture management
RewriteRule ^edit-pictures-album-([0-9]+)\.php editpics.php?album=$1 [NC]
RewriteRule ^edit-picture-([0-9]+)\.php editOnePic.php?id=$1&what=picture [NC]
RewriteRule ^picture-manager\.php picmgr.php [NC]

# Delete links
RewriteRule ^delete-comment-msgid-([0-9]+)\.php delete.php?msg_id=$1&what=comment [NC]
RewriteRule ^delete-album-([0-9]+)\.php delete.php?id=$1&what=album [NC]
RewriteRule ^delete-picture-([0-9]+)\.php delete.php?id=$1&what=picture [NC]
