Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8870019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:37:09+00:00 2026-06-14T17:37:09+00:00

I am developing a website using Codeigniter. i want to redirect a URL to

  • 0

I am developing a website using Codeigniter.

i want to redirect a URL to its SEO Friendly version. for eg.
I have URL

A. http://www.example.com/post/[post-id]/

I want this URL to redirct to SEO Friendly version of itself

B. http://www.example.com/post/[post-id]/[post-title]

Just like stackoverflow is using and like redirecting A URL to B URL.

http://stackoverflow.com/questions/[question-id]/[question-title]

I was using 302 redirection in the Codeigniter until i read somewhere that if you are using 302 redirection.
then google might treat you as a Spammer
but then again when i saw Stackoverflow URL Pattern then i think its much better to have B version of URL.

So my Questions are:
1. Which redirection stackoverflow is using?
2. Is it better to Store the Slug for [post-title] in database or manually calculate it with url_title() function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:37:10+00:00Added an answer on June 14, 2026 at 5:37 pm

    create a private function in the posts controller for SEO friendly URLs for posts.

    private function _redirect($url) {    // $url = http://www.example.com/post/[post-id]/
      redirect($url . $this->post_title); // becomes http://www.example.com/post/[post-id]/[post-title]
      return;
    }
    

    You should have a post_title member variable set before redirection. Where ever you are calling a redirect() function, replace it with your private function _redirect() and you are good to go.

    by default its 302 redirect. To do a 301 redirect just add parameter to the redirect() function. e.g

    // with 301 redirect
    redirect($url . $this->post_title, 'location', 301);
    

    Note: In order for this function to work it must be used before anything is outputted to the browser since it utilizes server headers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing a login library for a website using CodeIgniter. The authentication
I am developing a website using Codeigniter that will have different subdomains for different
I am developing a website using MVC 3, I have a web setup project
I'm developing an online website (using Django and Mysql). I have a Tests table
I am developing a website using Django as the backend, and I want to
I'm developing a website using php, i want to know how can i protect
I am developing a website using zend framework. i have a search form with
I'm developing a website (using asp.net-mvc) with a SqlServer 2005 database. I have numerous
I am developing a website using asp.net c# and I want to put a
I am developing a website using Microsoft MVC3, and have built it upon the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.