RewriteEngine On
RewriteBase /dw/

# Ignore existing files and directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Story Groups
RewriteRule ^api/groups/?$ api/groups/read.php [NC,L]
RewriteRule ^api/groups/create/?$ api/groups/create.php [NC,L]
RewriteRule ^api/groups/([0-9]+)/delete/?$ api/groups/delete.php?id=$1 [NC,L]

# Stories
RewriteRule ^api/stories/?$ api/stories/read.php [NC,L]
RewriteRule ^api/stories/create/?$ api/stories/create.php [NC,L]
RewriteRule ^api/stories/([0-9]+)/?$ api/stories/read_one.php?id=$1 [NC,L]
RewriteRule ^api/stories/([0-9]+)/update/?$ api/stories/update.php?id=$1 [NC,L]
RewriteRule ^api/stories/([0-9]+)/delete/?$ api/stories/delete.php?id=$1 [NC,L]

# Locations
RewriteRule ^api/locations/?$ api/locations/read.php [NC,L]

# Export/Utilities
RewriteRule ^api/export/chapters/?$ api/export/chapters.php [NC,L]
RewriteRule ^api/upload/photo/?$ api/utils/photo_upload.php [NC,L]

# Prevent Apache from forbidding directory requests
DirectorySlash Off
