Skip to content

Instantly share code, notes, and snippets.

@camilstaps
Created April 18, 2016 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camilstaps/87a05c8de3904fc2cb10343037540dd9 to your computer and use it in GitHub Desktop.
Save camilstaps/87a05c8de3904fc2cb10343037540dd9 to your computer and use it in GitHub Desktop.
Factorial in Apache rewrite rules
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^just/(1*)/?$ /index.php?just=$1 [L]
RewriteRule ^add-and/(\w+)/1(1*)/(1+)(/.*)$ /$1/$2$3$4
RewriteRule ^add/(1+)/(1+)/?$ /add-and/just/$1/$2/
RewriteRule ^mul-and/(\w+)/(1+)/(1+)(/.*)$ /mul-and-b/$1/1/$2/$3$4
RewriteRule ^mul-and-b/(\w+)/(1+)/1/(1+)(/.*)$ /$1/$2$4
RewriteRule ^mul-and-b/(\w+)/(1+)/1(1+)/1(1*)(/.*)$ /mul-and-b/$1/$2$4/$3/1$4$5
RewriteRule ^mul/(1+)/(1+)/?$ /mul-and/just/$1/$2/
RewriteRule ^fac/(1+)/?$ /fac_b/11/$1
RewriteRule ^fac_b/(1+)/1/?$ /just/$1
RewriteRule ^fac_b/(1+)/1(1+)/?$ /mul-and/fac_b/$1/1$2/$2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment