Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

NEed help on Url Rewrite with Smarty

 
Post new topic   Reply to topic    Smarty Forum Index -> Help Wanted (commercial)
View previous topic :: View next topic  
Author Message
willer777
Smarty n00b


Joined: 14 Jul 2015
Posts: 2

PostPosted: Tue Jul 14, 2015 3:40 pm    Post subject: NEed help on Url Rewrite with Smarty Reply with quote

Basically I have a index.php file that is the central controller and the code is this one:

Code:

<?php
require '../libs/Smarty.class.php';

$smarty = new Smarty;


//Setup the url var we are looking for to control page display
$page_var = 'page';
$category_var = 'category';

//Using the $_REQUEST scope so that the page can be passed in via $_POST or $_GET
$page_request = $_REQUEST[$page_var];
$category_request = $_REQUEST[$category_var];

//This array holds the relationship between the page variable and the template to load.. This info could also be retrieved from a db
$pages = array (
            'home' => 'home.tpl',
            'about' => 'about.tpl',
            'partners' => 'partners.tpl',
            'category' => 'category.tpl'
            );

$category_titles = array (
      'graphics' => 'Graphics deals',
      'infographics' => 'Infographics deals',
      'icons' => 'Icons Deals',
      'fonts' => 'Fonts deals',
      'logos' => 'Logo deals',
      'courses' => 'Courses deals',
      'ebooks' => 'Ebooks Deals',
      'lightroom' => 'LightRoom Deals',
      'bundles' => 'Bundles deals',
      'themes' => 'Themes deals',
      'webservices' => 'Webservices deals',
      'photoshop' => 'Photoshop deals'
      );


//Check if the requested page was found in the menu
if ( array_key_exists ( $page_request, $pages ) )
   $template = $pages[$page_request];
//If not set the default page
else
   $template = 'home.tpl';


//Assign info to Smarty and display
$smarty->compile_id = $template;
//$smarty->caching = 1;
$smarty->assign('template', $template);
$smarty->assign('page_var', $page_var);
$smarty->assign('category_titles', $category_titles);
$smarty->assign('category_request', $category_request);
$smarty->display('index.tpl');
?>


and my index.tpl is something like that
Code:

{include file='header.tpl'}
{include file='slider.tpl'}
{include file=$template}



I'd like that my website behaves correctly rewriting an url like that:
mydomain.com/?page=category&category=logos
into one like the following:
mydomain.com/category/logos

I added a .htaccess file with the following rules but it does not work, nothing happens.
Code:

RewriteEngine On
RewriteRule ^([./]*)/([./]*)$ /?page=$1&category=$2 [L]


I asked to my provider and they told me that probably this is due to the variables I put in index.php, but actually it sounds to me nosense.

Have you got any idea?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1518

PostPosted: Tue Jul 14, 2015 4:58 pm    Post subject: Reply with quote

1. This is not a Smarty question.
2. RewriteRule .* index.php [querystringappend,last]
Back to top
View user's profile Send private message
willer777
Smarty n00b


Joined: 14 Jul 2015
Posts: 2

PostPosted: Wed Jul 15, 2015 3:43 pm    Post subject: Reply with quote

Thanks for your reply.
Actually I though I was getting lost with some Smarty configuration...
I'm a super beginner.

Your second point is a rule I have to add?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Help Wanted (commercial) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP