0

I have hostinger shared hosting plan. working on laravel project. For a domain my current file structure is this :

Public_html/
    Test/
        Public/
            .htaccess
            Index.html

I want to redirect to public folder (https://example.com/test/public) without showing the "public" in the url and this is .htaccess code is

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

It’s showing me 404 error, how fix this?

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Don't rewrite if the request is already for /public
  RewriteCond %{REQUEST_URI} !^/Test/public/

  # Don't rewrite if the file or directory exists
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Rewrite all other requests to public/
  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

This is not even working , what should I do?

1

1 Answer 1

1

I took the liberty to reformat your question so that the information you provided is actually readable. Please take care for future questions to do that yourself. It is in your own interest to ask a question such that it is easy to read ...

Your issue (most likely) is the location of that ".htaccess" file. If I interpreted your question correct, you placed it inside the "Public" folder. Where it won't get considered, since an incoming request does not target that folder. You should place that file in the top folder that is used as your DocumentRoot folder, so most likely Public_html.

Also you need to make sure that rewriting is enabled at all for that http host. We do not know the default settings of your provider or how to change such setting there. Consult the documentation or ask them.

And take care with upper case letters in your folder and file names. Keep in mind that internet server's are usually based on Linux systems, not MS-Windows, for obvious reasons (security). Linux uses case sensitive file systems. So a folder called "Test" is not targeted by a request to https://example.com/test because of the upper case of the "T" in it's name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.