phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
301 redirect dynamic pages in htacess Apache I'm going nuts

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » Apache mod Rewrite
::  
Author Message
VonHelvete



Joined: 02 Jun 2008
Posts: 1
Location: Sweden

301 redirect dynamic pages in htacess Apache I'm going nutsPosted: Mon Jun 02, 2008 11:37 pm    Post subject: 301 redirect dynamic pages in htacess Apache I'm going nuts

Howdy guys! I have a SEO config setup by a company in my htacess which makes my whole webstore SEO friendly and to html. Problem is I need to redirect 301 all my old products, categories, documents to the new urls but I will stay on the same domain.

I have read, searched, tried everything for 2-3 days now and I'm going insane! I know it must be something easy for someone that have some experience but I'm a newbie and need some help Laughing

What I want/need to do for all my old pages is redirect like
Code:
THIS: http://www.domain.se/view_product.php?product=N811 TO: http://www.domain.se/panos-bikini-20/panos-bikini-bastia-17.html


Anyone? Seems like the dynamic url is the reason that I can't get it working since I tried with static and it worked fine =/
Thanks in advance!!!! Razz
Back to top
SeO
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3477

301 redirect dynamic pages in htacess Apache I'm going nutsPosted: Tue Jun 03, 2008 8:06 am    Post subject: Re: 301 redirect dynamic pages in htacess Apache I'm going nuts

Well, the problem is, this cannot be done through the .htaccess, unless you're ready to implement a rewriterule per page, because the title is not know before php/mysql retrieves it, and the .htaccess is processed before php.

So, the solution is to do it in the php script, like we do for phpBB3 with the zero duplicate, eg :

  1. At the beginning of the script, grab the uri ($_SERVER['REQUEST_URI']), in you example you should end up with : view_product.php?product=N811

  2. As soon as the product tile is queried for in the script, build the attended uri => panos-bikini-20/panos-bikini-bastia-17.html

  3. and compare the two. Using the = sign may be harder to set up for the edge cases, strpos() can be a good compromise in some circumstances (is the uri grabbed part of the attended uri ?)

  4. redirect upon negative match (= or strpos) using an http 301 header. This must be done before the script starts to output any content.


Depending on your script it may be more or less difficult to implement, but the principle is rather simple.

_________________
phpBB SEO || SEO Forum || Forum Référencement
GYM Sitemap & RSS for phpBB3 has been released ! || GYM Sitemap & RSS for phpBB3 est disponible !
Back to top
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » Apache mod Rewrite
Page 1 of 1

Navigation Similar Topics

Jump to: