0

I have a site tha is written in PHP and pulls data from a MySql DB. The site utilises query strings and I would like to map the query generated pages to the more search engine friendly page titles. For example I would like to acheive to the following mappings:

content.php?id=1 to map to /aboutus 
content.php?id=2 to map to /contactus
content.php?id=3 to map to /newfiles

how can i do this, in a more simple way. is that simply changing .htaccess file, or is that related to rewrite mapping function. pls can you give me hint and exact example would be great. thanks

1 Answer 1

1

You need a field called permalink (or similar) in your database. e.g.

id | permalink | content |
1  | aboutus   | bra bra |
2  | contactus | bra bra |

Then use this in your .htaccess file

RewriteRule ^(.*)/ content.php?permalink=$1 [L]

What above .htaccess does is recognize your url in first level and pass it to url variable. e.g. when user type

yoursite.com/aboutus/

It will actually request to

yoursite.com/content.php?permalink=aboutus

(but user don't see it)

then you use $_GET['permalink'] to match your database and get content display on the screen.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.