how to mirror directory with htaccess? - .htaccess

is it possible to mirror directory with htaccess?
For example:
/folder1 <= is empty
/folder2/blah/blah <= here is content
I want folder1 to display folder2 contents. So that when you go to folder1/ you can navigate to folder1/blah/blah/files
is this possible?

Alias can do this, although folder1 shouldn't exist for it to work:
Alias /folder1 /folder2/blah/blah
In .htaccess files, you can only Alias to a directory inside the web root.
It doesn't always work in .htaccess files, depending on the server configuration.
In the central configuration, you may have to use an absolute path as the Alias target.

Related

Redirecting from Sub Directory to Root Directory

I have 2 directories in my public_html directory as MainSite & OtherSite.
Now I want the following:
1 If a user enters my domain on it's root address, for instance www.example.com he must be redirected to my MainSite directory as I have all of the contents there.
2- But if user enters a subaddress, i.e. www.example.com/othersite, then he must be redirected to the OtherSite directory.
I know 1 can be done easily by pointing this folder for my main domain then in this case where to put my htaccess file and what do I write in that?
I don't want any other directory or sub directory contents to be disturbed.
So, what is a better approach?

Find files in not readable directory LINUX

How to find all files in non readable directory
For example directory /home is locked perm 40700
But I can read all files in this directory like
/home/index.php and etc
How to list all files in this directory?
I tryed ls and find function do not want to find thoose files
The r permission of folders determines whether you can list the contents. If a folder has x but not r, then you can access files as long as you know their names.
An example for this is to allow users to publish HTML documents in their home folders. For this, set the permissions for /home/user to rwx-----x and /home/user/public_html to rwx---r-x
That way, the HTML server can access the folder (it can walk though your home folder) but it can't see any files outside of the public_html folder.

Rsync syntax to copy specific subfolders

Alright so my web server has the following file structure
/
/home
/home/username
/home/username/public_html
/home/username/mail
/home/username/etc
...
/home/username2
/home/username2/public_html
...
So im trying to figure out a way of doing a cronjob that does a rsync wich will only synchronise the public_html folder of the 600 accounts i have. I thought of maybee doing an exclusion list with every other subfolder name there is under the accounts directories but i wasn't sure that was the optimal solution
Is there a way of telling rsync to only sync the content of the public_html folders without having to manually type in the 600 accounts?
Thanks
PS.: My current solution was something amongst the lines of :
rsync –vaRu –exclude ‘mail*’ -exclude 'etc*' home root#xxx.xxx.xxx.xxx:home
With this solution if any filenames match the directories name they won't be copied over.
You can do it using three filters:
rsync -av --filter="+ /home" \
--filter="+ /home/*" \
--filter="+ /home/*/public_html" \
--filter="+ /home/*/public_html/**" \
--filter="- *" / root#xxx.xxx.xxx.xxx:mirror
It is important to add a "+" filter for all the directories in the tree before the public_html and the "**" to include everything behind public_html.
The only drawback is that all the home directories will be created on destination but just as empty dirs.

Protect specific directories with .htaccess

Is it possible to protect specific directories with a single .htaccess and .htpasswd file?
I can only seam to find the ability to protect single files, or an entire directory (and it's sub directories)?
E.g .htpasswd in /public_html/myfolder
and protect
/public_html/myfolder/secret
/public_html/myfolder/admin
but not
/public_html/myfolder/mypublicfiles
htaccess files are a per directory options, it's sort of like a <Directory> block but defined by where you put the htaccess file. So you can't arbitrarily setup HTTP authentication on a directory other than the directory that the htaccess file is in.

Apache and linux file permissions can't browse file or directories

I just copied my magento site over to a local server running CentOS 5.4. The browser said it can't locate the location of the stylesheets. The stylesheets are within /skin/frontend/my_new_interface/design2/css. I tried to view in the browser and I can't view any of the files within the css directory. I verified a million times that I'm typing in the correct location. I can view files within /skin/frontend/my_new_interface/design2. Can't browse directories within browser however.
I typed in ls -l css
and get:
-rwxr-xr-x 1 apache apache
listed for all the files
I tried chmod -R 755 and the directories
I changed the apache conf Options Indexes
But still when I browse the directories I get Forbidden. However, in another fresh installation of magento in the same www dir, I am able to browse directories. As far as I can tell both installations have same ownership and permissions.
I also tried
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
which was recommended in the magento wiki
I've just run out of ideas.
You'll need to add Options +Indexes to your httpd.conf or in a .htaccess file in the css/ folder to view the folder contents through the browser. This is bad ju-ju though. Do you really need to switch this on, or can you keep doing it through the ssh session?
On the CSS file note, can you type pwd when in the CSS directory? That'll help us confirm you've got the correct location. Do you get "Forbidden" when you try to view the CSS file directory, or just when you try to view the directory contents?
The file permission were set up correctly. I figured out that the .htaccess had a rewrite rule set for the css directory that was causing the problem. I inherited this site and am still not aware of all the little modifications done throughout.

Resources