php - Mask outgoing links -



php - Mask outgoing links -

on php web page, i'm displaying html5 player plays mp3 track, , there's download button next that. want mask download link only, visitors not able see directory tree of server (www.example.com/content/plugins/audio/downloads/test.mp3). want alter link more simple , smaller (www.example.com/download/test.mp3) without changing folders construction of server.

i'm not sure if .htaccess or php thing.

thanks in advance.

with .htaccess need next rewrite rule:

$ pwd /var/www $ cat .htaccess rewriteengine on rewriterule ^/download/(.*\.mp3) /content/plugins/audio/downloads/$1 [nc]

it match http://yourdomain.com/download/….mp3 requests , redirect http://yourdomain.com/content/plugins/audio/downloads/….mp3

if want .htaccess work within subdirectory, utilize rewritebase:

$ cat subdirectory/.htaccess rewriteengine on rewritebase /subdirectory rewriterule ^download/(.*\.mp3) content/plugins/audio/downloads/$1 [nc]

i.e. http://yourdomain.com/subdirectory/download/….mp3 http://yourdomain.com/subdirectory/content/plugins/audio/downloads/….mp3

php .htaccess download

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -