2

I'm having some issues how to build a website template with clean url's.

I have the following files and directories in my root:

.htaccess (redirects every call to a non-existing file or directory to index.php)
index.php
/includes which contains header.php and footer.php
/pages with the requested pages
/ajax

So, in my index.php I process the url like this:

$urlParts = explode('/', $_SERVER['REQUEST_URI']);

so i can include the page from the pages dir based on the first entry in $urlParts which represents the passed page.

SO far so good.

Now I'm a little stuck with ajax calls, because I use two kinds of calls offcourse, the get and post. Until now, I just calles ajax files with their full path, so for example /ajax/account/login.php But I want to make clean urls from all my ajax calls.

Now I have some questions about this: 1. when doing an ajax post, should I just let it pass my index.php and include the ajax file? Or is it overkill because I include the header.php and footer.php and therefore do an extra check in my index.php if it's an ajax file and not include the header.php and footer.php

  1. When doing an ajax get, it is offcourse also passed to index.php and with a select I parse the ajax url and do a php redirect to the corresponding php file

So an include for a post and a redirect for a get.

Is this a good way to build my template? I just want to check it here because I want to reuse is for some websites so it has to be good and solid :)

randomizer
  • 1,619
  • 3
  • 15
  • 31

0 Answers0