I am new to htaccess, and really bad with regex, so here goes nothing...
I am building a pretty simple and basic web application. I have 5 pages, that handle everything in the application.
- home.php
- login.php
- content.php
- admin.php
- error.php
home handles just the homepage; login handles just the login and account creation; content handles all the other pages in the site; admin handles just the admin portion that is behind the login; error handle errors - clearly
In order to achieve this I have had to work out some quirky htaccess rules. The login form is submitted via ajax, so that was the first hurdle.
I have gotten the login to successfully redirect to the admin portal and the admin portal will show up, but the logout will not work and none of the ajax functionality inside the admin portal will work.
here is my htaccess so far:
#I have no idea what this line does
Options -Indexes
# Turn on rewritting
RewriteEngine On
# This will get the admin portal to load it needs to go through the admin controller
# not content, but nothing inside admin works
# /admin - works!
# /admin/save, /admin/logout, /admin/getPage all fail and are submitted via ajax
RewriteCond %{REQUEST_URI} ^/(.*)/admin$
RewriteRule ^(.*)$ index.php?url=admin/default/ [L,NC,QSA]
# this let's the login form submission via ajax work successfully, otherwise it gets
# processed by the last rule as a content page - it needs to go through the login
# controller, not content.
RewriteCond %{REQUEST_URI} ^/(.*)/login/login$
RewriteRule ^(.*)$ index.php?url=login/login/ [L,NC,QSA]
# this handles all the other pages in the site successfully
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=content/default/$1 [L,NC,QSA]
I have been searching the internet for answers to this all day, and what I have may be completely wrong, if so please let me know, and let me know why and how to fix it (those last two are optional I suppose). Once I get this working, my application will be ready. All help will be sincerely appreciated.