⌈⌋ branch:  freshcode


Artifact Content

  • File .htaccess — part of check-in [e98c1f377a] at 2014-12-29 14:11:37 on branch trunk — Addition of redir/ script for obfuscated URLs (not sure if needed though). (user: mario

Artifact 0f89fbf448ecbf1fa3f64710f51f5e1a43f4e17a:


# encoding: UTF-8
# api: apache
# title: RewriteRules
# description: Map paths onto dispatcher script
# version: 1.0
# depends: mod_rewrite


Options -MultiViews
RewriteEngine On

#-- Simulate [END] flag
RewriteCond  %{ENV:REDIRECT_STATUS}  =200
RewriteRule  ^                  -                       [L,NS]

#-- Strip www. prefix
RewriteCond  %{REQUEST_METHOD}  ^GET$
RewriteCond  %{HTTP_HOST}       ^ww+\.(\w+\.\w+)\.?$
RewriteRule  ^(.*)$             http://%1/$1            [R=301,QSA,L]

#-- RSS/Atom aliases
RewriteCond  %{QUERY_STRING}    ^format=(atom|rss|json)$
RewriteRule  ^$ feed/xfer.%1
RewriteRule  ^(?:projects)\.(atom|rss|json)$  feed/xfer.$1

#-- Freecode API mapping
RewriteCond  %{REQUEST_METHOD}  ^GET$
RewriteRule  ^projects/([\w-_]+)\.json$  index.php?page=api&name=$1&api=query [L,NS,QSA]
RewriteCond  %{REQUEST_METHOD}  ^PUT$
RewriteRule  ^projects/([\w-_]+)\.json$  index.php?page=api&name=$1&api=update_core [L,NS,QSA]
RewriteCond  %{REQUEST_METHOD}  ^POST$
RewriteRule  ^projects/([\w-_]+)/releases\.json$  index.php?page=api&name=$1&api=publish [L,NS,QSA]
RewriteCond  %{REQUEST_METHOD}  ^(GET|DELETE)$
RewriteRule  ^projects/([\w-_]+)/releases/(\w+)\.json$  index.php?page=api&name=$1&api=version_%1&id=$2 [L,NS,QSA]
RewriteCond  %{REQUEST_METHOD}  ^(GET|PUT|POST|PUSH)$
RewriteRule  ^projects/([\w-_]+)/urls\.json$  index.php?page=api&name=$1&api=urls [L,NS,QSA] 


#-- Page dispatching
RewriteRule  ^index/?$		/			[R=301,L]
RewriteRule  ^$                 index.php?page=index    [L,NS,QSA]
RewriteRule  ^(projects|submit|search|flag|names?|tags?|feed|login|links|rc|admin|github-releases|drchangelog)\b/?(\w+(?:[-_]\w+)*(?:\.\w{2,7})?)?(?:\.(json|atom|rss))?/?$   index.php?page=$1&name=$2&ext=$3   [L,NS,QSA]
RewriteRule  ^(url|go)/(\w+(?:[-_]\w+)*)/(\w+)/?$   index.php?page=redir&name=$2&ext=$3   [L,NS,QSA]
RewriteRule  ^(forum|meta)\b/?(\w+)?/?$   page_forum.php?name=$2   [L,NS,QSA]

#-- Deny direct invocations
RewriteRule  ^freshcode\.db.*$  -                       [F]
RewriteRule  ^\.                -                       [F]
RewriteCond  %{ENV:REDIRECT_STATUS}  !200
RewriteRule  ^\w+\.php(|/.*)$   -                       [F,L,NS]


#-- invalid resources
RewriteRule ^favicon\.(png|ico|jpeg)$ http://freshcode.club/img/changes.png [R=301,L]