1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Tweak the htaccess file

Discussion in 'Apache' started by Windranger, Aug 6, 2018.

  1. #1
    I want to map the name of an actual folder to a dummy folder name used in php / html, using htaccess file.

    So on the server I have this real folder called 'mydata' which contains many php files and subfolders.

    When I retrieve data from this folder, in php or html files, I want to write the path as 'somedata', instead of 'mydata'; for example: /somedata/mydatafile.php instead of /mydata/mydatafile.php. So the 'mydata' folder name will be always hidden from users for security reasons. 'somedata' is just a name, there isn't an actual folder on the server.

    I have a few addon domains beside the main domain, and the same mydata folder exists on each add-on domain too. The structure in cPanel is:

    '/public_html/mysite.com/mydata'
    '/mysite2.com/mydata'
    '/mysite3.com/mydata'

    where mysite.com is the main domain and the others are addons.

    The htaccess file should map 'somedata' folder name to 'mydata' folder name, in any path in any domain and addon-domain, so I would place it in the root (is root considered where public_html, mysite2.com and mysite3.com sites are?) I prefer to do it without redirect, the simplest way possible for the server.

    With RewriteEngine On, I tried the following:

    1.
    Alias /somedata /mydata

    2.
    RewriteRule ^mydata/(.*)$ /somedata/$1 [NC,L]

    3.
    RewriteCond %{REQUEST_URI} ^/somedata
    RewriteRule .* /mydata/ [NC,L]


    I'm stuck because of the syntax, can we make at least one work...?
     
    Windranger, Aug 6, 2018 IP