part 1 apache url mapping and redirect

Alias /doc/ "/usr/share/doc/"

if any other new directory except document root then it must be published with <Directory /your/directory/> </Directory>

AliasMatch
==========
AliasMatch ^/docs/(.*pdf) /var/www/docs2/$1

#$1 is first parenthesized block (.*pdf)<=its called reference


#anything terminating with pdf suffix

AliasMatch ^/docs/(.*pdf|txt) /var/www/docs2/$1
#anything terminating with pdf OR txt suffix
AliasMatch ^/docs/(.*) /var/www/docs2/$1
#reroute every thing to/docs2

AliasMatch ^/(docs)/(projectx)/(.*) /var/www/$2/$1/TXT/$3
#same as above but variablized

AliasMatch ^/(docs)/(projectx)/(.*\.pdf) /var/www/$2/$1/PDF/$3

                                                                                                                       

Redirect sends client to new destination
remaps url path beginning with '/' to new url
implementation of mod_alias as Redirect, RedirectMatch , RedirectPermanent, RedirectTemp
dafault status : 302
301: permanent
302:temporary

Redirect /docs  /docs2
#docs is redirected to docs2

Redirect /docs http://192.123.12.33/docs
#sends client to remote system

Redirect /docs http://www.google.com/docs

#invoke-rc.d apache2 reload


#  Using Redirect Match

RedirectMatch (.*)\.doc  $1.pdf #applies .pdf substitution across the site
eg.  google.com/docs2/TXT/file.doc

google.com/docs2/TXT/file # this is preserved and
.doc is replaced with .pdf and redirected


RedirectMatch /docs/(.*)\.doc /PDF/$1.pdf
anyfile terminating with .doc extension is redirected with same scheme
and same server









No comments:

Post a Comment