Disable access to a subfolder using .htaccess - .htaccess

I have a site in /public_html folder and I have another one in /public_html/addondomain.com.
I want to disable acesss to www.domain.com/addondomain.com but users should still be able to access www.addondomain.com (contained inside public_html/addondomain.com/ folder). I have an .htaccess in public_html folder. How do I do this?
Thanks in advance.

Try:
RewriteRule ^addondomain.com /this.file.does.not.exist

Related

Redirect domain to subfolder, from subfolder

My friend's dad asked me to change the design of his website, so he gave me access to his account and I created a sub-folder where I uploaded the new design. The problem is that he has forgotten the password to his control panel and I only have access to the FTP in the sub-folder. I'm trying to redirect the domain (currently going to the root folder) to the sub-folder but since I don't have access to the root folder I'm finding it difficult to do so.
I've already tried a redirect with .htaccess but since I can only upload the file to my sub-folder, it thinks the redirect is to a sub-folder within that folder, instead of the folder inside the root.
TL;DR...
I want to redirect 'mydomain.com' to 'mydomain.com/folder' but only have access to the FTP in 'mydomain.com/folder'.
Thanks in advance!
.htaccess applies to the directory that contains it.
You cannot change this if you have not access to vhost.conf files (what would change the base dir of the site) or to the parent directory’s .htaccess.
You will need to:
Reset your dad’s friend’s password and forget this redirect, changing the existing web files (the cleanest way), or
change the .htaccess file in your parent's dad directory, adding this:
RewriteEngine on
RewriteRule ^/?(.*)$ dir2/$1 [R=301,L,P]
This should redirect the user to dir2, hiding that redirect in the urlbar.
h/t #Alejandro Teixeira Muñoz for the edits!

Protecting Laravel Root Directory

I'm having a problem with denying access to the root directory of my Laravel Site...
I have my project in xampp/htdocs/laravel
Of course Laravel routes the /public directory...
But how can I deny access to the directory xampp/htdocs/laravel ...?
How can I prevent the directory listing?
The only way I've found is putting an index.php with a header("location: /laravel/public")
But I dont know if it's the best way... should I use .htaccess? How?
I've tried a few but it results in major errors across the server.
You need to open your httpd.conf file (xampp/apache/conf/httpd.conf) and change the "DocumentRoot" value to include the path to your public folder:
DocumentRoot "C:/xampp/htdocs/laravel/public"
Or just add a .htaccess with :
RewriteEngine On
RewriteRule ^ public [L]

Can't access to my Magmi subfolder in my Magento folder

I useing Magmi to import/export products, but when I visit my Magmi subfolder (www.mysite.com/magmi/web/magmi.php) is allways redirect me to my homepage. If I rename - delete - move - turn off the magento main folder .htaccess file I can access to my Magmi subfolder. Can somebody help me please how I can visit the Magmi subfolder without turning of the main .htaccess file?
Inside your Magento's .htaccess just after RewriteBase line add this rule:
RewriteRule ^magmi/ - [L,NC]
This will skip Magento's rewrite handling for /magmi/ URIs.
Add this to your .htaccess file in the magmi folder:
ErrorDocument 401 "Unauthorized Access"
This way, the browser will ask for a user/password, instead of 404'ing.
(See https://serverfault.com/questions/55323/disable-mod-rewrite-for-subdirectory)
in my case, the magmi folder had the wrong permissions. Try setting 755 permission on magmi folder and subfolders

RewriteRule to access folder outside public folder

My .htaccess file is redirecting requests to the public_html folder.
For example, http://mydomain.com/file.html would show root_folder/public_html/file.html.
However, I would like it to show root_folder/anotherfolder/file.html instead.
Is it possible to do so?
I think you want
Alias /file.html root_folder/anotherfolder/file.html

Allowing/Disallowing directory listings with .htaccess

I have a wordpress site running, and currently anyone can view the uploads directory by visiting
http://site.com/wp-content/uploads
I want to stop this directory from being viewed in a browser but I want a subfolder to be viewable (eg. http://site.com/wp-content/uploads/PublicUploads). I have tried setting
IndexIgnore *
in the uploads folder, but I cannot work out how to set the sub folder back to visible.
Any help would be appreciated
Most people use
Options -indexes
To make a subdirectory visible again, you'll need to put a .htaccess file inside that subdir, with Options +indexes inside it.
Using mod_rewrite you can block direct access to wp-content/uploads directory like this:
RewriteRule ^wp-content/uploads/?$ - [F,NC]
Keep in mind that this will only block browsing of /wp-content/uploads contents but will allow /wp-content/uploads/PublicUploads or any /wp-content/uploads/foo.

Resources