It's my first time deploying a web app on a hosting and they give me this .htaccess but i've never configured one, i have a root directory then a public_html and at the same level my webpage. i'll show you the directory tree and the content of the .htaccess
root
|
|---project
|---public_html
|---.htaccess
The content of the .htaccess is:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (. )/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And when I enter the website it's showing me a http 403 error: Server or website configuration is blocking you from viewing this page.
I have never configured a website on a hosting so I don't know what i'm doing most of the time...
Thx!!
CodePudding user response:
root | |---project |---public_html |---.htaccess
Assuming public_html
is the document root (where your public facing files and index.php
are located) then the .htaccess
file should be in the public_html
directory itself (not above it).
That is...
root
|
|---project
|---public_html
|------.htaccess
By placing the .htaccess
file in the root
directory (above the document root) then it would attempt to rewrite the request to /root/index.php
(as opposed to /root/public_html/index.php
) which is inaccessible (from rewriting in .htaccess
) and does not exist anyway, so would likely result in a 403, 400, etc.