IntactDev
Member
- Nov 22, 2012
- 399
- 71
I'm trying to add a new feature to my TPL system. I want to be able to add the ability to have multiple URL segments, like (profile/Username/Photos). Right now, I can only do one segment (profile/). How can I add more? I'm learning HTACCESS and I took a shot. My TPL system uses the first segment to identify which page to return... but, I now want it to check if the first segment is profile. Here is the pseudo verson:
Here is my current HTML:
Here is the current PHP:
How can I go about doing this? I hope this is enough info,
IntactDev
PHP:
if(First Segment is == profile) {
check the second segment, and return that page template
} else {
continue code
}
Here is my current HTML:
Code:
RewriteEngine On
RewriteRule ^(|/)$ index.php?url=$1
RewriteRule ^([a-zA-Z0-9_-]+)(|/)$ index.php?url=$1
RewriteRule ^profile/([a-zA-Z0-9_-]+)(|/)$ index.php?url=$1&username=$2
Here is the current PHP:
PHP:
public function addTpl() {
global $zip;
if(!isset($_GET['url']) || empty($_GET['url'])) {
$_GET['url'] = 'index';
}
if(file_exists('_zip/_templates/_front/'. $zip['Template']['Front'] . '/')) {
if(file_exists('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php')) {
ob_start();
include('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php');
$this->tpl .= ob_get_contents();
ob_end_clean();
} else {
die(zipError('File Not Found', 'The file <b>' . secure($_GET['url']) . '</b> could not be found. Please re-check the URL; If you were directed here using a link, please report that link.'));
}
} else {
die(zipError('Template Not Found', 'The template <b>' . $zip['Template']['Front'] . '</b> could not be found. Please check your configuration file for a mistake.'));
}
}
How can I go about doing this? I hope this is enough info,
IntactDev