views:

28

answers:

1

Hi all, i'm struggling with an htaccess rewrite command

what I have is

RewriteCond %{HTTP_HOST} ^www.mywebsite.co.uk$
RewriteCond %{REQUEST_URI} !^/subfolder/ 
RewriteRule ^(.*)$ /subfolder/

I have a few URLs going to the same folder, some of them redirect to subfolders, which then run different templates. However, I also need to append a parameter to the end of every page that is reditected, eg, ?template=2

I can't just add it to the end manually, becuase some pages already have paremeters, eg /?product=1 - so the second parameter needs to have the & sign not the ? sign.

Any help appreciated

Jon

+2  A: 

You just need to add the QSA flag on the end of your rule:

RewriteRule ^(.*)$ /subfolder/?template=2 [QSA]
Conspicuous Compiler