Dr.Kameleon
Dr.Kameleon

Reputation: 22820

Redirections + CodeIgniter + SEO?

OK, so here's my situation :

The issue :

How should I do it? Which one is the most SEO-friendly way? Will there be any drawback?

Please, do shed some light, 'coz I'm simply too confused and definitely don't wanna ruin an already fine-performing website...

Upvotes: 0

Views: 1453

Answers (4)

Aurel
Aurel

Reputation: 3740

As i know only post_name is important in uri of WP post: wp-site.com/category/post_name is equal to wp-site.com/category2/post_name.

So when you migrate your wp-posts tables to your new CI posts table, keep post_name field to identify the content requested.

i submit you a simple solution to keep old URLs or not:

e.g: Your olds URIs is like /category1/cateogry2/post_name/

config/route.php

//old post URIs (WP)
//$3 = post_name
$route['([a-z0-9\-_]+)/([a-z0-9\-_]+)/([a-z0-9\-_]+)/'] = 'posts/single/$3'; 

//new post URIs
//e.g: /post_name.html
$route['([a-z0-9\-_]+)\.html'] = 'posts/single/$1';

controllers/posts.php

//posts method
public function single($post_name) {
    //check post_name in DB
    //...

    //check URI (optionnal)
    //there are not one segment in the uri so this is an old URI
    if( $this->uri->total_segments() > 1 ) {
        redirect($post_name.'.html', 301);
    }

    //...
}

By this solution, when you will access http://site.com/category1/cateogry2/post_name/, posts/single method will be called and redirect you to the new URL http://site.com/post_name.html if you want.

Upvotes: 1

Wayne Tun
Wayne Tun

Reputation: 589

You may use $slug variable . Using $slug to store the URL might probably help. I had never tried with SEO before but probably might work.

http://ellislab.com/codeigniter/user-guide/tutorial/news_section.html

seem like you may be able to store

xxx.com/category/some-category/some-subcategory/content_title

to

xxx.com/$slug/content_title

All you will might probably need to edit $slug with previous URL(s). Give it a try.

Upvotes: 1

Abhishek Salian
Abhishek Salian

Reputation: 934

Be carefull SEOMoz cheat didnt work for me. My site was usually on 2nd page of google search. After following SEOmoz It dropped my site below 5th page. I know a SEO guru, when I showed my site he laughed and told me "not to believe everything said on internet, they tell crap just to get viewers". He suggested me to keep urls as short as possible and have one specific keyword in the url, having category, sub category,..... will make a lengthy url and google treats it as keyword stuffing. I changed my urls to short & sweet and within 3 weeks my site was on the 1st page.

Yes 301 redirection is best as m4t1t0 mentioned above. According to google if you change your website domain name or url to a page u should use 301, by which you can preserve your previous backlinks & page ranks.

Add this in your .htaccess file

Redirect 301 /category/some-category/some-subcategory http://mysite.com/specific-keyword-for-the-product

Upvotes: 1

m4t1t0
m4t1t0

Reputation: 5731

My recomendation, change the URL structure using friendly URL, here you can find a good cheat sheet with the anatomy of a good URL: http://www.seomoz.org/blog/seo-cheat-sheet-anatomy-of-a-url

Additionally to the anterior point, you need to maintain the old URL structure doing 301 redirections (this is quite important, do not use 302) to the new structure. You can do this in your .htaccess file. More info: http://www.seomoz.org/learn-seo/redirection

Upvotes: 1

Related Questions