You are here:  » htaccess 301 redirect

Support Forum



htaccess 301 redirect

Submitted by chrisst1 on Wed, 2012-10-24 11:21 in

Hi David

As you know we have a multiple PT installation setup under one domain, in the root we have the following rewrite rule to ensure search engines only spider the www. alias and avoid duplicates.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oursite\.com$ [NC]
RewriteRule ^(.*)$ http://www.oursite.com/$1 [R=301,L]

This works fine on all none pt pages but where we have the following rules for each installation the above rule no longer functions and individuals are able to link to http://oursite.com/products.php?q= etc. Is it possible to alter the rule below to include the above rule

Options -MultiViews

RewriteEngine On

RewriteBase /compare-uk/bodycare-haircare/

RewriteRule ^product/(.*).html$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

RewriteRule ^review/(.*).html$ reviews.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

RewriteRule ^merchant/$ merchants.php
RewriteRule ^merchant/(.*)/$ search.php?q=merchant:$1:&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^merchant/(.*)/(.*).html$ search.php?q=merchant:$1:&page=$2&rewrite=1&%{QUERY_STRING} [L]

RewriteRule ^category/$ categories.php
RewriteRule ^category/(.*)/$ search.php?q=category:$1:&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^category/(.*)/(.*).html$ search.php?q=category:$1:&page=$2&rewrite=1&%{QUERY_STRING} [L]

RewriteRule ^brand/$ brands.php
RewriteRule ^brand/(.*)/$ search.php?q=brand:$1:&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^brand/(.*)/(.*).html$ search.php?q=brand:$1:&page=$2&rewrite=1&%{QUERY_STRING} [L]

Thanks

Chris

Submitted by support on Wed, 2012-10-24 11:32

Hi Chris,

Exactly the same 2 lines;

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

...can go after the RewriteEngine On line in the individual .htaccess of each Price Tapestry installation, that should do the trick!

Cheers,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Wed, 2012-10-24 12:23

Hi David

Tried that, can't get it to work, still returns address without www.

Chris

Submitted by support on Wed, 2012-10-24 13:09

Hi Chris,

Ah - it may need to go after RewriteBase, and include the sub-dir, e.g.

RewriteBase /compare-uk/bodycare-haircare/
RewriteCond %{HTTP_HOST} ^oursite\.com$ [NC]
RewriteRule ^(.*)$ http://www.oursite.com/compare-uk/bodycare-haircare/$1 [R=301,L]

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Wed, 2012-10-24 14:49

If the above doesn't work for you, try changing the beginning of the last line.

RewriteBase /compare-uk/bodycare-haircare/
RewriteCond %{HTTP_HOST} ^oursite\.com$ [NC]
RewriteRule (.*) http://www.oursite.com/compare-uk/bodycare-haircare/$1 [R=301,L]

What worked for us...

Submitted by chrisst1 on Wed, 2012-10-24 14:58

That worked!

Thanks David