Whenever you publish information underneath class ‘Funding’ which has class Id Three in database and gave publish title ‘Finest long run funding choices in India’ which has a publish id 207 in database. Your publish URL will comprise these Ids so that it’ll acknowledge the publish have to show to person.
1
|
www.mydomain.com/information.php?cid=3&pid=207
|
This strategy of making URL has few points.
- Not human readable/pleasant
- Lacking vital searchable Key phrases
- It’s not Search Engine pleasant
Serps and customers might have issues with difficult URLs. A transparent, easy and descriptive URL can be extra attraction-sicker to each Human and Search Engines.
Pleasant URL
Search engine pleasant or human-readable or clear URLs are URLs that make sense to each people and search engines like google and yahoo as a result of they clarify the topic of the Web page/Put up it’s pointing to.
Let’s see how we will create a Search Engine pleasant URL utilizing .htaccess and PHP. It is advisable first allow apache mod_rewrite module for this code to work.
Following PHP code will convert your parametric URL into Search Engine Pleasant URL.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
perform _prepare_url_text($string){
$match_char = ‘#[^-a-zA-Z0-9_ ]#’;
$string = strtolower($string);
$string = preg_replace($match_char,”,$string);
$string = trim($string);
$string = preg_replace(‘#[-_ ]+#’,‘-‘,$string);
return $string;
}
perform create_final_url($class, $subcat, $article_name, $article_id) {
$class = _prepare_url_text($class);
$subcat = _prepare_url_text($subcat);
$article_name = _prepare_url_text($article_name);
$final_url = $class . ‘/’ . $subcat . ‘/’ . $article_identify . ‘-A’ .$article_id . ‘.html’;
return $final_url;
}
$url = create_final_url(‘Finance’, ‘Funding’,
‘Finest long run funding choices in India’, 207);
|
Calling create_final_url perform will convert to www.mydmain.com/finance/funding/best-long-term-investment-options-in-india-A207.html
Be sure to add following htaccess rule in your .htaccess file.
1
2
3
4
5
6
7
8
9
10
11
12
|
## Apache Mod Rewrite Guidelines
## Written for www.techzoo.org
## Developer : Tousif Khan
# Earlier than Proceding ON the Apache mod_rewrite Engine
# By writing following command.
RewriteEngine on
# Pattern Rule – used as a Refrence
RewriteRule ^/?([a–zA–Z–]+)/([a–zA–Z–]+)/.*–A([0–9–.]+).html$
article.php?cat=$1&subcat=$2&article=$3 [L]
|
Supply techzoo.org