.htaccessurldirectoryurl-masking

Use .htaccess to load files from different folders


I have many files in directory /full/

that's why I would like to spread files to /full1/, /full2/, /full3/ folders on server but to save original URL like

http://my-domain.com/full/article-with-text

to determine which files are where to put I'd like to define it on the URL mask like

^/full/a$ from folder /full1/

^/full/b$ from folder /full2/

tell me please how to build correct .htaccess ?


Solution

  • Try this

    RewriteRule ^full/a(.+)?/?$ http://my-domain.com/full1/a$1 [NC,L]
    RewriteRule ^full/b(.+)?/?$ http://my-domain.com/full2/b$1 [NC,L]
    RewriteRule ^full/c(.+)?/?$ http://my-domain.com/full3/c$1 [NC,L]
    ...
    RewriteRule ^full/z(.+)?/?$ http://my-domain.com/full26/z$1 [NC,L]
    

    e.g,

    http://my-domain.com/full/a-one.txt will mask the url http://my-domain.com/full1/a-one.txt