S
S
solo452020-10-10 22:16:47
htaccess
solo45, 2020-10-10 22:16:47

How to change the index file?

Good day, how to change the index file in another folder /public/index.php
so that when you go to the site there is no error 403
www.yoursite.com so that it opens like this, and not like www.yoursite.com/public
read what you can through. htaccess
in the public folder, it is there, but I don’t know how to write it

here. Here is the .htaccess code

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect index.php to /
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
ge, 2020-10-11
@gedev

The question is not very clear. As far as I understand, you need to change the site's root directory from www.yoursite.com/public to www.yoursite.com. You can do it in .htaccess like this:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
  
RewriteCond %{REQUEST_URI} !^/(public)
RewriteRule (.*) /public/$1
  
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /public/index.php

If you have access to the Apache settings, then it's easier to change the DocumentRoot. If not, you can replace the folder that is the DocumentRoot with a symbolic link to the public/ folder.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question