0

Please how can I rewrite

Could anybody please rewrite this url?

http://localhost/display_news_cat.php?news_cat_id=14&p=2

to

http://localhost/display_news_cat/14/2

Thank you

1

4 Answers 4

3

Create an .htaccess file in the site directory and add the following lines

RewriteEngine on
RewriteRule ^display_news_cat/([\d]+)/([\d]+)$ display_news_cat.php?news_cat=$1&p=$2
Sign up to request clarification or add additional context in comments.

Comments

1

Afaik, this is normally accomplished with Apache .htaccess file rewrite rules. Is you case this would look something like:

RewriteEngine on
RewriteRule ^display_news_cat/([0-9]+)/([0-9]+)$ display_news_cat.php?news_cat_id=$1&p=$2

If this doesn't work, try checking your access logs to see what's happening.

2 Comments

Working but had to Change to ---RewriteEngine on RewriteRule ^display_news_cat/([0-9]+)/([0-9]+)$ display_news_cat.php?news_cat_id=$1&p=$2
aha yes, cut and paste error. I've updated it for future reference.
1

there are different ways to archive this, and it takes only 1 minute to find this out yourself using google. you could:

  • use an .htacces file with rewrite-rules to let the apache do the rewriting
  • map everything on localhost/ to an index.php, read and parse the request-string "by hand" hand show the correct site

Comments

0

Also you can hold it in one script use GET to retrieve the values you wish and re-create the URL with that values. I don't know if it will help you.. Anyway a .httacess file will be much more useful for you.

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.