Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Tweak in htaccess file


  • Please log in to reply
1 reply to this topic

#1 windranger

windranger

  • Members
  • 32 posts
  • OFFLINE
  •  
  • Local time:10:27 AM

Posted 06 August 2018 - 09:44 AM

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...?

 



BC AdBot (Login to Remove)

 


#2 Nicola0226

Nicola0226

  • Members
  • 6 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:North-West, England
  • Local time:01:27 AM

Posted 03 September 2018 - 04:37 PM

try

 

generate .htacces in each of the sites /mydata/ folder, and add:

 

RewriteBase /mydata/
RewriteRule . /somedata/ [L]





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users