How to change link in core php
4 answers
Like this ... based on the little information you gave ....
$link = 'localhost/project/search?uni=1';
$link = str_replace('?uni=1', '/uni-of-uk', $link);
NEW: in PHP you can change the title to change the url.
if($_GET['uni']==1)
{ header('Location: localhost/project/search/uni-of-uk');
exit;
}
The important thing is that you DO NOT EXIT until you call the header function. Therefore, before any exit, you must place this code on top of your script.
0
source to share
What you are looking for is called URL Rewriting
.
You can achieve this using mod_rewrite
(assuming you are using apache).
You might want to look into this mod_rewrite article
0
source to share
If you want to change
localhost/project/search?uni=1
to
localhost/project/search/uni-of-uk/1
You can achieve this by creating .htaccess in your root folder and adding something like this to it,
RewriteEngine on
RewriteRule ^/?search/uni-of-uk/([0-9]+)$ /search?uni=$1
Another method is PHP routing , large CMS sites follow this method as stated here .
0
source to share