Options +FollowSymLinks
RewriteEngine On

# On some servers the url rewrite didn't work; in that case try uncommenting this line and write your path there, e.g /gallery
# RewriteBase /gallery

RewriteRule ^admin(/)?$ admin.php [QSA]
RewriteRule ^admin-categories(/)?$ admin_categories.php [QSA]
RewriteRule ^admin-category-edit(/)?$ admin_category_edit.php [QSA]
RewriteRule ^admin-regenerate-images(/)?$ admin_regenerate_images.php [QSA]

RewriteRule ^login(/)?$ login.php [QSA]
RewriteRule ^logout(/)?$ logout.php [QSA]
RewriteRule ^upload(/)?$ upload.php [QSA]


# rewrite the URL of photos, to avoid the "/files" path in URL
RewriteRule ^([^/]+)/([^/]+)_thumb.jpg$ files/$1/$2_thumb.jpg [QSA]

# the thumbnail of the category
RewriteRule ^([^/]+).jpg$ files/$1/thumbnail.jpg [QSA]

# the _small.jpg (display image)
RewriteRule ^([^/]+)/([^/]+)_small.jpg$ files/$1/$2_small.jpg [QSA]

# read the note at the end of this file about the "B" flag
RewriteRule ^([^/]+)/edit-photos/?$ admin_edit_photos.php?cat_url_string=$1 [B,QSA]

# before matching this greedy rule, test if file exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

# read the note at the end of this file about the "B" flag
RewriteRule ^([^/]+)/?$ category.php?cat_url_string=$1 [B,QSA]

# !!!
# the "B" flag inside [B,QSA] was added to help some server process category names that contained spaces
# try removing the "B," if it causes problems with spaces in category names
# !!!
