john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

cherokee redirect

vServer -> Rules -> Add Rule (plus symbol) -> Regular Expression ->

^/SOMEPATH/(.*)$

Handler -> Redirection ->
  Type: External
  Regular Expression (add new RegEx): ^/SOMEPATH/(.*)$
  Substituion: http://new.example.com/$1

basically the incoming request that matches the regular expression (i.e. anything with path SOMEPATH/ is given a 301 redirect ^ means begins with (assuming the host part has already been truncated by cherokee web server matches slash SOMEPATH slash exactly and literally the parenthesis indicate anything else after will be saved in a variable the . means any character and * means any number of repetitions until the end (which is the $ symbol) and the new requst will be the new external domain with everything after SOMEPATH replacing the $1 variable

Note the redirection rule should probably be before any other fall through rules (like php or whatever) and it should be final

Hint: once you have learned the power of redirects (though learning regex can be crazy difficult and only validated through lots of trial and error) make sure you also redirect the subdirectory itself (otherwise you will generate 500 errors that will not help your SEO)

Add New RegEx -> Show: External
  Regular Expression: ^/SOMEPATH/$
  Substitution: http://new.example.com/SOMENEWPATH/

  • « Git branch diff server init stash undo uncommit ssh config forward agent
  • ram made easy »

Published

Jan 7, 2016

Category

cherokee

~193 words

Tags

  • cherokee 7
  • redirect 8