skip to Main Content

Lets say I have http://example.com as my website.

Now, when I do http://example.com/api/login, the login script works.

But when I do http://example.com, it goes straight to the default switch cause in my router setup for index.php in the htaccess file which shows echos Access Denied.
It doesnt show the website in either case.

All files are in the public_html folder for hosting.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]

Thats my current htaccess file. What do I do to fix this problem?

2

Answers


  1. Chosen as BEST ANSWER

    I fixed it by creating a new folder in public_html called backend I changed the htaccess to

    RewriteEngine On
    RewriteBase /backend/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)$ index.php [QSA,L]
    

    I placed all things related to the backend there and it works now


  2. What are the contents of your base folder? By default php will always open index.php file if you want to head for the login page instead which in your case is http://example.com/api/login then edit your index.php file to redirect to it with

      die(header("location: http://example.com/api/login"));
    

    placed at the top of the index.php script

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search