Jan 27, 2020

URL rewrite rules are pretty helpful in producing SEO friendly URLs for your blogs and projects

By Ashish Patel
1 min read

It is a very good idea for keeping your URL more understandable for normal people who are reading the blog. Like if you look at the URL of this page you can easily get what is getting loaded like you are at worldsofashishpatel.com and you are seeing this blog which has a title as URL says. Instead of URL which includes queries like (eg. www.example.com ? blog_name=something ) that would be a real pain to understand for users and that is not really good for SEO too. Here is the case where URL rewrite rules come to play its role.

Rewrite rule on server .htaccess file

You can perform this rewrite thing on your servers.htaccess configuration file. by adding rewrite rules that will actually redirect the queried URL like "www.example.com?blog_name=something" into "www.example.com/something". which just looks cleaner and natural. Here is the easy tutorial from mediatemple.net to learn Rewrite Rules.

But let me warn you if you are using direct PHP into your page then it just works fine but if you are using asynchronous request to PHP using AJAX then you must specify the rewrite rule according to your base directory. Here is the source I found from StackOverflow which helped me a lot in writing rewrite rules for AJAX requested files.

This is how the Rewrite Rule Syntax looks like :

Blog Embed Image

SEO friendly

These URLs are easier for Google crawlers to crawl in your pages through URL and sitemap and when your blog gets indexed it shows a much cleaner URL.

Blog Embed Image