Ticker

6/recent/ticker-posts

Learn PHP: what is URL Rewriting?

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.

Image by <a href="https://pixabay.com/users/alekseynemiro-2293495/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2060502">Aleksey Nemiro</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2060502">Pixabay</a>

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.


URL Rewriting


The above URL show in the picture change to the URL display in as below Picture.

URL Rewriting

URL Rewriting


Above URL Change to below URL

URL Rewriting


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]


URL Rewriting


In the Above post if we left anything please comment to us so we can update it soon.



Post a Comment

2 Comments

  1. 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

    ReplyDelete