I've rewritten this question now as I don't think the problem is to do with the URL rewrite.
I'm building a site with PHP and Smarty and using fairly common url rewriting using apache's mod rewrite.
Locally, if I visit: example.com/search/?q=test, I get search results for "test". /search is not a real directory, it's forwarding to search.php?q=
When I upload, it's not working. I've enabled rewrite with sudo a2enmod rewrite
and the url is updating, the browser shows example.com/search/?q=test in the address bar, doesn't throw a 404, but just serves up my index.php page instead.
I've realised the problem is probably to do with my Smarty caching. I've got a URL variable that triggers the cache to be rebuilt, ?rebuildCacheNow.
If I go to /account, I get the index page, but if I go to /account?rebuildCacheNow the account page shows up.
If I then go back to the index, /, it still shows the account page. Going to /?rebuildCacheNow shows me the home page.
This is my main Smarty template:
{* Smarty *}
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"><![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"><![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"><![endif]-->
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
{include 'head.tpl'}
<body id="top">
{include 'header.tpl'}
<div class="content-container">
<div class="container content">
{include $page.content}
</div>
</div>
{include 'footer.tpl'}
<script src="{$JQUERY_CDN}"></script>
<script src="{$BOOTSTRAP_JS_CDN}"></script>
<script src="/js/main.js"></script>
{$page.scripts}
</body>
</html>
Every page serves up this template, but I'm using PHP to assign $page.content
. So the /buy page sets $page.content = 'buy.tpl'
and /search sets $page.content = 'search.tpl'
.
But it looks like the main.tpl
is being cached - is there a better way of using 1 main outline template and embedding content templates within?