Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule Append Query String Help

Need htaccess rule to append query string to end of url on a sub-domain.

         

Giancarlo

5:25 pm on Apr 30, 2009 (gmt 0)

10+ Year Member




I am having a htaccess rule problem. I have to somehow force and append a query string "?tpl=Fgs" to the end of every url on a sub-domain.

The extra query string is simply to switch styles, but needs to execute for the sub-domain.

Here's where it get's tricky. The sub-domain is cloaked! All original files are based on the primary domain. So any thing I came up with, reflects back on the primary domain.

I have to make the stlye appear and force the extra query string only on the sub-domain.

This is what I have to accomplish

http://subdomain.domain.com/URL-GOES-HERE?tpl=Fgs

This is the current htaccess file

<Files ATBSlicense.txt>
Deny from all
</Files>

RewriteEngine on

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(/Cart.*¦.*\.(gif¦jpg¦css¦js))$
RewriteCond %{REQUEST_FILENAME} !(/index.php)$
RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [R,L]

RewriteCond %{HTTPS} !=on
RewriteRule ^Cart(.*) https://%{SERVER_NAME}/Cart$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1&%{QUERY_STRING}

Please, someone help me out. Any ideas out there?

jdMorgan

9:38 pm on Apr 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post the code you've tried to use.

Hints:
1) You will need to use a RewriteCond to check %{HTTP_HOST} for the subdomain requests.
2) You should probably use %{HTTP_HOST} in the RewriteRule substitution, instead of %{SERVER_NAME}
3) You will need to use the [QSA] flag to append new query data to the existing query, rather than replacing it.

Jim