Alex S
asked on
Tweak in htaccess file
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/m ydata'
'/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...?
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/m
'/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...?
ASKER
Thanks. According to what you say
"if someone attempts to access mydata, it would redirect them to somedata."
it seems it is the other way around.
Please read the post again- the information should be read from 'mydata' folder which is the real folder on disk.
Thanks
"if someone attempts to access mydata, it would redirect them to somedata."
it seems it is the other way around.
Please read the post again- the information should be read from 'mydata' folder which is the real folder on disk.
Thanks
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
This should work, and in cases if someone attempts to access mydata, it would redirect them to somedata.