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 8447261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:08:27+00:00 2026-06-10T10:08:27+00:00

If I have a dynamic page, where it takes in an id parameter like

  • 0

If I have a dynamic page, where it takes in an id parameter like example.com/posts.php?id=2, how do I make a RewriteRule in htaccess so that the url shows the title of the post rather than its id, so for example posts.php?id=2 shows a post with a title of “PHP is cool”, I want the url to be rewritten like example.com/2/php-is-cool or something like that? Would that be possible if the title value is stored in a MySQL database?

Additional Info:

This is how my htaccess looks like:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

ErrorDocument 404 /index.php
ErrorDocument 403 /index.php
php_value post_max_size 20M

Basically, I have a MySQL database which stores blog posts in a table called posts. The posts table has an id attribute (which is the auto-increment primary key), a title attribute, and a content attribute. When I access mydomain.com/posts.php?id=X, it will show my post with an id of ‘X’ from the database on the webpage. I just want to be able to re-write the URL such that it shows the title of the page. I’m doing this primarily for SEO, not aesthetics. Is this possible using htaccess, or would I have to approach this differently?

  • 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-10T10:08:29+00:00Added an answer on June 10, 2026 at 10:08 am

    Rewrite rules apply to the way the URL is handled on your backend (apache). Using mod_rewrite to rewrite those URLs will not affect what the user is seeing in their browser’s URL bar unless you redirect the user to a new URL (using a 302 redirect, for example), which would cause the browser to reload the page.

    You can achieve what you’re asking for using the HTML5 pushstate feature (with a fallback to URL hashes if pushstate is not supported in that browser).

    Take a look at this URL for more details:

    http://badassjs.com/post/840846392/location-hash-is-dead-long-live-html5-pushstate

    Also, you could use BackboneJS and its Router feature to handle your page and URL handling logic in the browser.

    http://backbonejs.org/#Router

    This is a very application specific kind of solution and this answer cannot go into more details without knowing your exact configuration, application logic, etc.

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

Sidebar

Related Questions

I would like to make a web application (PHP) that will have overlay container
I have a dynamic page that gets a certain number of results for rooms
i have a dynamic php web page localhost/ctd/index.php All working good except if i
I have a dynamic drop down box which calls another PHP page. I've got
I have a page that includes a dynamic js-script depending on the page I'm
I have a web page that displays dynamic data which changes every 2 seconds.
I have a page that has primarily dynamic content generated by Ajax . It
I have dynamic web page with JS. There is a <textarea> and a Send
Is it possible to render Razor in Html.Raw()? I have a dynamic page being
I have been working on a dynamic page http://www.euroworker.no/order and I want my lovely

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.