Forum Moderators: phranque

Message Too Old, No Replies

Redirecting Products fine but not Subdirectory

         

KoolRifz

12:26 am on May 25, 2011 (gmt 0)

10+ Year Member



I've got my products redierecting fine thanks to g1smd albeit not in a database yet... view thread here: [webmasterworld.com...]

My issue is that all my specific redirects are working (I've got 700+ of them):
RewriteCond %{QUERY_STRING} (^|&)products_id=1183(&|$) 
RewriteRule ^index\.php$ http://store.musicplace.com.au/cd-s-and-dvd-s/449-breakthrough-to-improv-the-secrets-of-improvising.html? [R=301,L]
RewriteCond %{QUERY_STRING} (^|&)products_id=1184(&|$)
RewriteRule ^index\.php$ http://store.musicplace.com.au/cd-s-and-dvd-s/450-i-love-the-trumpet.html? [R=301,L]
RewriteCond %{QUERY_STRING} (^|&)products_id=1757(&|$)


but I can't get a rewriterule to point my subdirectory to the new subdomain:

RewriteCond %{HTTP_HOST} ^(www.)?\musicplace\.com\.au [NC]
RewriteCond %{HTTP_HOST} !=www.musicplace.com.au
RewriteRule ^/catalogue(.*) http://www.store.musicplace.com.au$1 [R=301,L]


I've tried this in my root .htaccess and my subdirectory.

Sorry! I'm been searching and dreaming this stuff but at the moment it is more of a nightmare...

KoolRifz

6:54 am on May 25, 2011 (gmt 0)

10+ Year Member



My ZenCart that I want to redirect is not at root it is in the dir "catalogue" - musicplace.com.au/catalogue

I've put my .htaccess in catalogue (root of zencart) with the following code. Why doesn't it redirect the request for musicplace.com.au/catalogue to store.musicplace.com.au ?


Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?musicplace\.com\.au$
RewriteRule ^catalogue/(.*) http://store.musicplace.com.au/$1 [R=301,L]

RewriteCond %{QUERY_STRING} (^|&)products_id=1183(&|$)
RewriteRule ^index\.php$ http://store.musicplace.com.au/cd-s-and-dvd-s/449-breakthrough-to-improv-the-secrets-of-improvising.html? [R=301,L]
RewriteCond %{QUERY_STRING} (^|&)products_id=1184(&|$)
RewriteRule ^index\.php$ http://store.musicplace.com.au/cd-s-and-dvd-s/450-i-love-the-trumpet.html? [R=301,L]


This is gutting me!

Thanks,
Rob

g1smd

7:41 am on May 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If the first redirect had worked, then none of the other rules in your .htaccess file would have been processed. The (.*) says to redirect ALL requests. The rule order is important. This rule must be listed last so that the other rules are processed first, with control handed to the (.*) rule only if none of the other rules applied to the current request.

That line of code would have redirected /catalogue requests had the .htaccess file been placed in the root. However, when that code is in the /catalogue/ folder, you must omit catalogue/ from your RegEx pattern. URLs are localised "per-folder" before being presented to mod_rewrite for processing.

By the way, you're redirecting HTML page requests to the new site but what are you doing about images? You could simply force "410 Gone" for those, or you could redirect them. (You don't need to redirect stylesheets or javascript, force "410 Gone" for those.) Whatever you do, do not "funnel" thousands of URLs to the new site homepage.

KoolRifz

10:34 am on May 25, 2011 (gmt 0)

10+ Year Member



YES! Finally a victory. WIll 410 the images.
Thanks. I'll be back in a week or so to follow up the database idea for rewriting disused URLs.