Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
[HTACCESS] Multiple URL Segments
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="IntactDev" data-source="post: 209646" data-attributes="member: 24757"><p>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:</p><p> </p><p>[PHP]if(First Segment is == profile) {</p><p>check the second segment, and return that page template</p><p>} else {</p><p>continue code</p><p>}[/PHP]</p><p> </p><p>Here is my current HTML:</p><p>[CODE]RewriteEngine On</p><p> </p><p>RewriteRule ^(|/)$ index.php?url=$1</p><p>RewriteRule ^([a-zA-Z0-9_-]+)(|/)$ index.php?url=$1</p><p> </p><p>RewriteRule ^profile/([a-zA-Z0-9_-]+)(|/)$ index.php?url=$1&username=$2[/CODE]</p><p> </p><p>Here is the current PHP:</p><p>[PHP]public function addTpl() { </p><p> global $zip;</p><p> </p><p> if(!isset($_GET['url']) || empty($_GET['url'])) {</p><p> $_GET['url'] = 'index';</p><p> }</p><p> </p><p> if(file_exists('_zip/_templates/_front/'. $zip['Template']['Front'] . '/')) {</p><p> if(file_exists('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php')) {</p><p> ob_start();</p><p> include('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php');</p><p> $this->tpl .= ob_get_contents();</p><p> ob_end_clean();</p><p> } else {</p><p> 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.'));</p><p> }</p><p> } else {</p><p> die(zipError('Template Not Found', 'The template <b>' . $zip['Template']['Front'] . '</b> could not be found. Please check your configuration file for a mistake.'));</p><p> }</p><p> }[/PHP]</p><p> </p><p>How can I go about doing this? I hope this is enough info,</p><p> </p><p>IntactDev</p></blockquote><p></p>
[QUOTE="IntactDev, post: 209646, member: 24757"] 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: [PHP]if(First Segment is == profile) { check the second segment, and return that page template } else { continue code }[/PHP] 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[/CODE] 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.')); } }[/PHP] How can I go about doing this? I hope this is enough info, IntactDev [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
[HTACCESS] Multiple URL Segments
Top