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

  • Home
  • SEARCH
  • 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 8230105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:01:40+00:00 2026-06-07T17:01:40+00:00

We run a blog, and really need to tidy up the URLs using htaccess,

  • 0

We run a blog, and really need to tidy up the URLs using htaccess, but I am really stumped.

Example:

Working on a site, and I need to generate search engine friendly URLs

So I have the url currently as:

http://mywebsite.com/blog/read.php?art_id=11

Title of this page is:

Why do Australians pay so much for Cars ?

I need to change it to its corresponding SEF url. like so:

http://mywebsite.com/blog/Why-do-Australians-pay-so-much-for-Cars-?

The question mark is part of the title, and we could remove these if its a issue. Any suggestions please?

Also would prefer to drop the read.php portion. Need to create a rule that works across our entire blog.

They all follow the same pattern, only the art_id number changes.

  • 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-07T17:01:48+00:00Added an answer on June 7, 2026 at 5:01 pm

    (Assuming that you’re using apache as a webserver)

    Take a look at this answer for a very similar question: https://stackoverflow.com/a/8030760/851273

    The problem here is that .htaccess and mod_rewrite doesn’t know how to map page names to art_id’s so there’s 2 ways you can try to do this.

    1. You can add some functionality to your read.php so that it can do a similar lookup but instead of art_id, it uses art_title or something. Essentially you’ll have to do the backend lookup of a database (or wherever your articles are stored) and use the title as a key instead of the ID. This is a little messy since it’s possible to have weird characters in titles such as non-ascii or reserved characters (like ? for instance), so you’ll need to create a title encoder and decoder when pulling titles out of the database or when using titles to lookup an article in your database.
    2. If you have access to the server config or vhost config, you may be able to setup a RewriteMap using an outside program (the prg type) and create a php script that does the title-to-ID lookup for you. Then you can create rewrite rules in your .htaccess that does something along the lines of:

      RewriteRule ^blog/(.*)$ /blog/read.php?art_id=${title-to-id:$1} [L]
      

      Where you are extracting the article title from your pretty URL, and feeding it through a rewrite map called title-to-id to get the art_id. Again you’ll need to setup a title encoder/decoder so your titles will have the non-ascci and reserved characters dealt with.

    Another thing that you can do is to stick an article ID in your pretty URLs so they look like this: http://mywebsite.com/blog/11-Why-do-Australians-pay-so-much-for-Cars. This is still pretty easy to see what the link is about, it’s SEO friendly, and it bypasses the need to do title-to-ID lookups. The Rewrite Rules would also equally be simpler:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # add whatever other special conditions you need here
    
    RewriteRule ^blog/([0-9]+)-(.*)$ /blog/read.php?art_id=$1 [L]
    

    And that’s it. Of course, you’d have to now generate all of your blog URL’s to be of the form: http://(host)/blog/(art_id)-(art_title), and you’d also have to remove special characters from the title, but you don’t have to worry about writing additional code to translate titles back to IDs.

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

Sidebar

Related Questions

I run a site using the MODx Content Management System. What I'd like to
I run my blog using Wordpress and all too recently became a big believer
I run a website that allows users to write blog-post, I would really like
I am following the directions here http://blog.heroku.com/archives/2011/8/29/play/ but I do play run and then
I'm trying to run a multi domain blog installation with WordPress and Nginx. The
im trying to get the funnelweb blog application to run on my machine, ive
I downloaded the xVal sample project from Steve Sanderson’s blog , run it, and
I run a local directory website (think yelp/yell.com etc) and need to provide analytical
Not really a programming question, but I can't think of anywhere else to ask.
I want to run a user-agent check but only on my homepage (static_controller#home) I

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.