#
# Hey! Everything in here is better suited to httpd.conf, since
# we get a performance boost if we can turn off AllowOverride and
# not have to stat the webroot for every request. On the other
# hand, this means we never have to touch apache once it's up.
# Flexibility over performance.
#
# In an ideal world, you'd stick it in here on dev and your build
# system would bundle the changes into (a file included in) httpd.conf
# for your production deployment. Yeah. Do that.
#
# ETags are a bad idea if you have multiple web servers. We'll do
# more explicit caching with Expires headers anyway.
FileETag none
# The base set of sensible PHP options. You could put these in your
# php.ini file too, but having them in your Apache config puts
# everything in one place. Magic quotes off because they are stupid.
# Register globals off for the same reason. Track errors is so that
# we can at least get at the error messages we hide using @func().
# last_modified is a bad idea if we have any dynamic content. Short
# tags make for a few saved bytes of cruft and are fine unless you're
# running another XML preprocessor over your code (wtf?).
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value magic_quotes_runtime 0
php_value track_errors 1
php_value last_modified off
php_value short_open_tag on
php_flag display_errors on
# See also: $GLOBALS['cfg']['uploads_by_email_maxbytes']
# I would like to find a way to sync these two things...
php_value upload_max_filesize 5M
# this sets all current and future error flags on, except for E_NOTICE
# which can go fuck itself. we have some separate code for checking the
# one notice we do care about.
php_value error_reporting 2147483639
# Some basic pointers to php files
DirectoryIndex index.php
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
ErrorDocument 500 /500.php
# Get mod_rewrite fired up
RewriteEngine on
# The API (as in both api.example.com and example.com/api)
# Ensure that all traffic to the API proper is over HTTPS
# Note that this is a api.example.com host not example.com
# (20121025/straup)
# RewriteCond %{HTTP_HOST} ^api.(.*)$
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}/$1?%{QUERY_STRING} [R,L]
# The most basic rewrite, as this is the actual API
# RewriteCond %{HTTP_HOST} ^api.(.*)$
# RewriteRule ^rest/?$ api_rest.php?%{QUERY_STRING} [L]
# This one says: If we're the API and we're not hanging off /rest
# redirect to the site itself – note the %1% for capturing the domain
# sans 'api.' (20121025/straup)
# RewriteCond %{REQUEST_URI} !rest(.*)
# RewriteCond %{HTTP_HOST} ^api.(.*)$ [NC]
# RewriteRule .? http://%1%{REQUEST_URI} [R,L]
# RewriteCond %{HTTP_HOST} !^api.(.*)$
# RewriteRule ^api/rest/(.*)/?$ https://api.%{HTTP_HOST}/rest/?method=$1&%{QUERY_STRING} [R,L]
# RewriteCond %{HTTP_HOST} !^api.(.*)$
# RewriteRule ^rest/(.*)/?$ https://api.%{HTTP_HOST}/rest/?method=$1&%{QUERY_STRING} [R,L]
# The rest of the user/admin interfaces for doing API stuff
# This all (especially the oauth2 auth/token stuff) relies on the
# HTTPS rules for logged in users (20121024/straup)
RewriteRule ^api/?$ api.php [L]
RewriteRule ^api/methods/?$ api_methods.php [L]
RewriteRule ^api/methods/(.*)/?$ api_method.php?method=$1&%{QUERY_STRING} [L]
RewriteRule ^api/keys/?$ api_keys.php?%{QUERY_STRING} [L]
RewriteRule ^api/keys/register/?$ api_keys_register.php?%{QUERY_STRING} [L]
RewriteRule ^api/keys/([a-zA-Z0-9]+)/?$ api_key.php?api_key=$1&%{QUERY_STRING} [L]
RewriteRule ^api/keys/([a-zA-Z0-9]+)/tokens(/page([0-9]+))?/?$ api_key_tokens.php?api_key=$1&page=$3&%{QUERY_STRING} [L]
RewriteRule ^api/oauth2/?$ api_oauth2.php?%{QUERY_STRING} [L]
RewriteRule ^api/oauth2/howto/?$ api_oauth2_howto.php?%{QUERY_STRING} [L]
RewriteRule ^api/oauth2/authenticate/?$ api_oauth2_authenticate.php?%{QUERY_STRING} [L]
RewriteRule ^api/oauth2/authenticate/like-magic/?$ api_oauth2_authenticate_like_magic.php?%{QUERY_STRING} [L]
RewriteRule ^api/oauth2/access_token/?$ api_oauth2_access_token.php?%{QUERY_STRING} [L]
RewriteRule ^api/oauth2/tokens(/page([0-9]+))?/?$ api_oauth2_tokens.php?page=$2&%{QUERY_STRING} [L]
RewriteRule ^api/oauth2/tokens/([a-zA-Z0-9]+)/?$ api_oauth2_token.php?api_key=$1&%{QUERY_STRING} [L]
RewriteRule ^api/rest/?$ api_rest.php?%{QUERY_STRING} [L]
# Login stuff
RewriteRule ^invite/?$ invite.php?%{QUERY_STRING} [L]
RewriteRule ^invite(?:/([^/]+))?/?$ invite.php?code=$1&%{QUERY_STRING} [L]
RewriteRule ^auth/$ /auth_callback_flickr_flickrauth.php?%{QUERY_STRING} [L]
RewriteRule ^signin/$ /signin_flickr_flickrauth.php?%{QUERY_STRING} [L]
RewriteRule ^signup/$ /signup.php [L]
RewriteRule ^signout/$ /signout.php [L]
RewriteRule ^checkcookie/$ /checkcookie.php [L]
# Password retrieval stuff
RewriteRule ^forgot/$ /forgot.php [L]
RewriteRule ^reset/([a-zA-Z0-9]+)/$ /reset.php?reset=$1 [L,QSA]
# Account stuff
RewriteRule ^account/?$ account.php [L]
RewriteRule ^account/password/?$ account_password.php [L]
RewriteRule ^account/delete/?$ account_delete.php [L]
RewriteRule ^account/url/?$ account_path_aliases.php [L]
RewriteRule ^account/path_alias(es)?/?$ account_path_aliases.php [L]
RewriteRule ^account/uploadbyemail/?$ account_uploadbyemail.php [L]
RewriteRule ^account/backups/?$ /account/flickr/backups/ [R]
RewriteRule ^account/flickr/backups/?$ account_flickr_backups.php [L]
RewriteRule ^account/flickr/auth/?$ account_flickr_auth.php?%{QUERY_STRING} [L]
# API (old)
# RewriteRule ^api/?$ api_rest.php [L]
# RewriteRule ^api/methods/?$ api_methods.php [L]
# RewriteRule ^api/methods/(.*)/?$ api_method.php?method=$1&%{QUERY_STRING} [L]
# RewriteRule ^api/rest/(.*)/?$ api_rest.php?method=$1&%{QUERY_STRING} [L]
# Misc
RewriteRule ^photos/upload/oauthecho/?$ flickr_photos_upload_oauth_echo.php [L]
# Flickr stuff
RewriteRule ^photos/upload/?$ flickr_photos_upload.php?%{QUERY_STRING} [L]
RewriteRule ^photo.gne$ flickr_photo.php?%{QUERY_STRING} [L]
RewriteRule ^photos/me(/([a-z_]+))?/?$ flickr_photos_me.php?context=$2&%{QUERY_STRING} [L]
RewriteRule ^photos/friends(/page([0-9]+))?/?$ flickr_photos_friends.php?page=$2&%{QUERY_STRING} [L]
RewriteRule ^photos/friends/activity(/([a-z_]+))?/?$ flickr_photos_friends_activity.php?update_type=$2&%{QUERY_STRING} [L]
RewriteRule ^photos/friends/faves(/page([0-9]+))?/?$ flickr_photos_friends_faves.php?page=$2&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/activity/?$ flickr_photos_user_recent_activity.php?path=$2&nsid=$3&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))(/page([0-9]+))?/?$ flickr_photos_user.php?path=$2&nsid=$3&page=$5&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/with/([0-9]+)/?$ flickr_photos_user.php?path=$2&nsid=$3&with=$4&%{QUERY_STRING} [L]
RewriteRule ^buddyicon/([0-9]+@N[0-9]+).jpg$ flickr_buddyicon.php?nsid=$1 [L]
# Flickr push
RewriteRule ^push/([^/]+)/?$ flickr_push_receiver.php?secret_url=$1&%{QUERY_STRING} [L]
# Places
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/places(/([a-z]+))?/?$ flickr_photos_user_places.php?path=$2&nsid=$3&facet=$5&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/places/([a-z]+)(/(indoors|outdoors))?/?$ flickr_photos_user_places.php?path=$2&nsid=$3&facet=$4&context=$6&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/places/(d+)(/page([0-9]+))?/?$ flickr_photos_user_place.php?path=$2&nsid=$3&woeid=$4&page=$6&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/places/(d+)/(indoors|outdoors)(/page([0-9]+))?/?$ flickr_photos_user_place.php?path=$2&nsid=$3&woeid=$4&context=$5&page=$7&%{QUERY_STRING} [L]
# cameras
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/?$ flickr_photos_user_cameras.php?path=$2&nsid=$3&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/([0-9a-zA-z-_s+]+)(/page([0-9]+))?/?$ flickr_photos_user_camera.php?path=$2&nsid=$3&make=$4&page=$6&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/cameras/([0-9a-zA-z-_s+]+)/([0-9a-zA-z-_s+]+)(/page([0-9]+))?/?$ flickr_photos_user_camera.php?path=$2&nsid=$3&make=$4&model=$5&page=$7&%{QUERY_STRING} [L]
# calendar
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/archives(/date-(taken|posted))?/?$ flickr_photos_user_archives.php?path=$2&nsid=$3&context=$5&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/archives/(date-(taken|posted))/([0-9][0-9][0-9][0-9])(/page([0-9]+))?/?$ flickr_photos_user_archives_year.php?path=$2&nsid=$3&context=$5&year=$6&page=$8%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/archives/(date-(taken|posted))/([0-9][0-9][0-9][0-9])/([0-9][0-9])(/page([0-9]+))?/?$ flickr_photos_user_archives_month.php?path=$2&nsid=$3&context=$5&year=$6&month=$7&page=$9%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/archives/(date-(taken|posted))/([0-9][0-9][0-9][0-9])/([0-9][0-9])/([0-9][0-9])(/page([0-9]+))?/?$ flickr_photos_user_archives_day.php?path=$2&nsid=$3&context=$5&year=$6&month=$7&day=$8&page=$10%{QUERY_STRING} [L]
# photo pages
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/(d+)/?$ flickr_photo.php?path=$2&nsid=$3&id=$4&%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/(d+)/exif/?$ flickr_photo_exif.php?path=$2&nsid=$3&id=$4&%{QUERY_STRING} [L]
# faves
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/faves(/page([0-9]+))?/?$ flickr_faves_user.php?path=$2&nsid=$3&page=$5%{QUERY_STRING} [L]
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/faves/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))(/page([0-9]+))?/?$ flickr_faves_user.php?path=$2&nsid=$3&by_alias=$5&by_nsid=$6&page=$8%{QUERY_STRING} [L]
# contacts
RewriteRule ^photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/contacts(/page([0-9]+))?/?$ flickr_contacts_user.php?path=$2&nsid=$3&page=$5%{QUERY_STRING} [L]