.htaccess redirect for www in parent folder and children react

Posted by ServerChecker on Server Fault See other posts from Server Fault or by ServerChecker
Published on 2012-11-23T03:26:35Z Indexed on 2012/11/23 5:00 UTC
Read the original article Hit count: 363

Filed under:
|
|
|

We were having a problem with the Norton seal not showing up on our affiliate marketing landing pages (landers). Turns out, the Norton seal was super picky about the "www." prefix. I had folder paths like /lp/cmpx where x was a number 1-100 and indicated advertising campaign number.

So, to remedy this, I stuck this in my .htaccess file right after the RewriteEngine On line:

RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/lp/cmp1/$1 [R=302,QSA,NC,L]

Trouble is, I had to do that under every campaign folder, changing cmp1 to whatever the folder name was. Therefore, my question is... Is there a way I can do this with an .htaccess file under the parent folder (/lp in this case) and it will work for each of the children?

EDIT: Note that I stuck an .htaccess file in /lp just now to test:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/lp/$1 [R=302,QSA,NC,L]

This yielded no effect to the /lp/cmpx folders underneath, to my dismay.

© Server Fault or respective owner

Related posts about apache2

Related posts about .htaccess