WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-13-2007, 02:34 PM
thindenim's Avatar
WebProWorld Pro
 

Join Date: Jan 2007
Location: Scotland
Posts: 241
thindenim RepRank 1
Default 301 Redirect and htaccess problem

I'm currently in the final stages of a redevelopment of our girlznight web site. The structure of the site has changed slightly and consequently, quite a number of the URLs have changed.

I have added the following redirect rule for one of our products to the main htaccess file. NB, boys-talk.co.uk is just the domain I am using to test before going live: -

redirect 301 /shop/beauty/skintruth-face/skintruth-nourishing-cleanser.html http://www.boys-talk.co.uk/shop/skin...-cleanser.html

There is a rewrite rule used for the product urls, which is: -

RewriteRule ^shop/(.*)/(.*).html index.php?init=viewproduct&did=$1&pid=$2&menu=shop

So, in theory http://www.boys-talk.co.uk/shop/beau...-cleanser.html

should redirect to

http://www.boys-talk.co.uk/shop/beau...-cleanser.html

However, if you try to go to the first url, it directs you to http://www.boys-talk.co.uk/shop/skin...nser&menu=shop

which is the new url, with a query string (which seems to be derived from the old redirected url) whacked on the end.

Sorry to be a little long winded with the description, but it's hard to explain any other way.

Can anyone shed any light on this... it's driving me crazy!

Thanks in advance.
__________________
Girlz Night - professional hair and beauty products
Web design glasgow - from Thin Denim
Reply With Quote
  #2 (permalink)  
Old 03-13-2007, 03:31 PM
thindenim's Avatar
WebProWorld Pro
 

Join Date: Jan 2007
Location: Scotland
Posts: 241
thindenim RepRank 1
Default

Got it (I think) with 2 more Rewrite rules as opposed to the 301 rule: -

RewriteRule ^shop/(.*)/(.*)/(.*).html$ http://www.boys-talk.co.uk/shop/$1/$3.html [R=301,L]
RewriteRule ^shop/beauty/(.*).html$ http://www.boys-talk.co.uk/shop/skin/$1.html [R=301,L]

Would be grateful if someone could confirm that this would be search engine friendly. Many thanks.
__________________
Girlz Night - professional hair and beauty products
Web design glasgow - from Thin Denim
Reply With Quote
  #3 (permalink)  
Old 03-13-2007, 04:37 PM
incrediblehelp's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jan 2004
Location: Live in Cincy Now
Posts: 7,654
incrediblehelp RepRank 4incrediblehelp RepRank 4incrediblehelp RepRank 4incrediblehelp RepRank 4
Default

Here is the header response I get:

#1 Server Response: http://www.boys-talk.co.uk/shop/beau...-cleanser.html
HTTP Status Code: HTTP/1.1 301 Moved Permanently
Date: Tue, 13 Mar 2007 20:36:00 GMT
Server: Apache 3
Location: http://www.girlznight.co.uk/shop/bea...-cleanser.html
Connection: close
Content-Type: text/html; charset=iso-8859-1
Redirect Target: http://www.girlznight.co.uk/shop/bea...-cleanser.html

#2 Server Response: http://www.girlznight.co.uk/shop/bea...-cleanser.html
HTTP Status Code: HTTP/1.1 301 Moved Permanently
Date: Tue, 13 Mar 2007 20:36:01 GMT
Server: Apache 3
Location: http://www.girlznight.co.uk/shop/ski...-cleanser.html
Connection: close
Content-Type: text/html; charset=iso-8859-1
Redirect Target: http://www.girlznight.co.uk/shop/ski...-cleanser.html

#3 Server Response: http://www.girlznight.co.uk/shop/ski...-cleanser.html
HTTP Status Code: HTTP/1.1 200 OK
Date: Tue, 13 Mar 2007 20:36:01 GMT
Server: Apache 3
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Powered-By: PHP/4.4.4
Set-Cookie: PHPSESSID=f9fc4fdd6b1f53a5d68bb58712034890; path=/
Connection: close
Content-Type: text/html

is that what you want to happen?
Reply With Quote
  #4 (permalink)  
Old 03-13-2007, 07:26 PM
thindenim's Avatar
WebProWorld Pro
 

Join Date: Jan 2007
Location: Scotland
Posts: 241
thindenim RepRank 1
Default

Would probably be better doing it all in one step, however, would have to do it without the regular expressions and set up a rule for every page (500 or so). Will the 2 301 redirects in a row be accepted?

The page it ends up at is the correct one.

Edit: The site is now live actually, so girlznight.co.uk is correct, ignore the boys-talk.co.uk
__________________
Girlz Night - professional hair and beauty products
Web design glasgow - from Thin Denim
Reply With Quote
  #5 (permalink)  
Old 03-13-2007, 09:15 PM
incrediblehelp's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jan 2004
Location: Live in Cincy Now
Posts: 7,654
incrediblehelp RepRank 4incrediblehelp RepRank 4incrediblehelp RepRank 4incrediblehelp RepRank 4
Default

Quote:
Originally Posted by thindenim
Will the 2 301 redirects in a row be accepted?
I have never had an issue with them, they are just rare for me.
Reply With Quote
  #6 (permalink)  
Old 03-13-2007, 10:55 PM
thindenim's Avatar
WebProWorld Pro
 

Join Date: Jan 2007
Location: Scotland
Posts: 241
thindenim RepRank 1
Default

Thanks for the help... now trying to turn the layout into standards compliant css/xhtml and ditch the tables /:-(
__________________
Girlz Night - professional hair and beauty products
Web design glasgow - from Thin Denim
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0