Good day. I am having a little problem with my .htaccess file. In my website, I have the root directory as "Website" and the admin panel as "Website/backend".
I created the htaccess to direct to "index.php"s in each folder depending on the request. i.e website/about will direct to index.php in root folder and i also want website/admin/dashboard to redirect to index.php inside the backend folder.
The issue is I want the admin folder to be "backend" while the path will be "website/admin" for uniformity in my folder structure. For example, if I want to have a profile.php inside the backend folder but I want the path that will show on the browser to be admin/profile.
I have been having errors with this. It's either I get "object not found" or I get redirected to localhost/dashboard. My question: Is this achievable
This is my folder structure
My website
root_folder
index.php
.htaccess
backend
index.php
profile.php (for admins)
My .htaccess file is shown below
Options -Indexes -Multiviews +FollowSymLinks
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(?!admin/)(.+)$ /index.php?u=$1 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/admin(.+)$ /backend/index.php?u=$1 [NC,QSA,L]
</IfModule>
When I change /admin to /backend or when I create an admin folder with an index.php it also works. However, I want to be abe to access files inside backend folder while the browser is showing "admin" in the url.
Thanks.