Nginx - Configuration inside a webroot directory - .htaccess

How can I create a configuration file on a directory inside the webroot directory if I can't or don't want to set it up on sites-enable/domain.tld?
Just like in Apache, we can set up a .htaccess inside a directory.

Related

CodeIgniter 4: How to protect .env from public view?

I have configured the database credentials in the .env file. But I can access the file .env file from the browser and it displays all the variables in the .env file.
How do I make it secure so it is not publicly readable?
My folder structure is like this:
public_html/project/
.env
app
public
system
writable
The application is accessed from domain.com/project/public.
In fact you're not installing the project correctly on your server
The public_html folder should contain files that are intended to be accessible by the browser
In the case of CodeIgniter 4, the contents of the public_html folder are the contents of public folder, you usually put the front controller index.php and your assets folder inside public_html
The rest of folders and files goes next to public_html, so your folder structure needs to look like this:
|__.env
|__app
|__public_html
|____index.php
|____assets
|__system
|__writable
Try to prevent it from .htaccess
<Files .env>
Order allow,deny
Deny from all
</Files>

.htaccess load from sub folder but keep on showing main domain

I have a install that has a web folder that has the website stored in this. How can I make the domain load from this folder within the public_html folder.
The domain is like: sub.domain.co.nz
Don't put the entire Symfony project under the public_html folder - this will cause all of the project files to be accessible over the web, including .yml files that include sensitive information like database passwords!
Put the Symfony project files in a folder that is not web accessible. Then configure your web server so that the DocumentRoot points to the path of the web folder of the Symfony project, and also modify the paths of all the aliases.

.htaccess Folder Browsing

I have a "site" setup to allow myself some "public" downloads.
So in the root folder of the site I have an htaccess file containing
Options +Indexes
IndexOptions +FancyIndexing
Inside the site I have a couple folders with files for downloading, etc...
How can I disable the ability to get into the parent folder once inside one of these folders?
For instance...
http://o7thwd.com/dl/Mine
I'd like to prevent the Parent Directory from showing and being able to do anything...
Remove the .htaccess file from the site's root folder.
Put the following (same as in your question) in .htaccess file in every sub-folder that needs to be public:
Options +Indexes
IndexOptions +FancyIndexing

Unable to access assets folder in Codeigniter

My directory structure is as follows:
-application
-system
-assets
--images
--downloads
--css
index.php
I created assets as suggested on stackoverflow,I wanted to restrict access to downloads so placed .htaccess file in assets folder with the following directive
Deny from all
now its protected but as assets has css files and those are also not accessible too.
Try to put the htaccess file to downloads file

Redirect localhost subaddress to another folder

My "htdocs" folder is set to this: C:\webserver\xampp\htdocs
All my folders exist in subfolders of this folder.
I have such another folder here: c:\MyProjects\project1
I need to htaccess rewrite so, when I write: http://127.0.0.1/project1/myfile.php
On my browser, I will see the result of "myfile.php" inside "project1" folder.
Is it possible?
Is it possible?
No, you can't rewrite a URI outside of your document root, C:\webserver\xampp\htdocs. And htaccess file sitting in that htdocs directory won't be able to point a request outside of the htdocs directory. Mod_rewrite isn't what you want anyways. You want to use mod_alias from within the vhost config or server config. Something along the lines of:
Alias /project1 C:/MyProjects/project1
See also: Make XAMPP/Apache serve file outside of htdocs

Resources