URL Rewriting is a concept that allows PHP developers to use a URL that actually goes to another URL within the same website. This concept mostly used in dynamic websites so the final URL is SEO Friendly.
A good reason to use URL rewriting:-
a) SEO Friendly.
b) Search Engines
index the content of dynamic website pages slow as compared to a static website.
c) URL looked friendlier
to end-user.
d) Easy to
access and remember.
Example:- You
have an URL like http://localhost/php-test/url.php?=1
and http://localhost/php-test/url.php?=2
And want to change the URL to http://localhost/php-test/url/1
and http://localhost/php-test/url/2
by using URL rewriting. All the above links are landed to the same place but the
URLs like /url/1 and /url/2 are more valuable to search engines.
The above URL show in the picture change to the URL
display in as below Picture.
Above URL Change to below URL
For the above output, we have to make changes done in
.htaccess file.
Example:-
Write URL rewriting code under .htaccess file
Rewrite Engine on
RewriteRule
^url/([0-9])+)$url.php?-d=$1[L]
2 Comments
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. Learn PHP
ReplyDeleteThankyou dear!
Delete