Please URL Rewrite in php

后端 未结 4 1785
野的像风
野的像风 2020-12-22 12:18

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://local

相关标签:
4条回答
  • 2020-12-22 12:45

    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.

    0 讨论(0)
  • 2020-12-22 12:47

    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
    0 讨论(0)
  • 2020-12-22 13:02

    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
    
    0 讨论(0)
  • 2020-12-22 13:02

    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.

    0 讨论(0)
提交回复
热议问题