SEO Tips : Make SE friendly URLs with htaccess on Apache

You love LAMP or WAMP? Either way you got Apache server and if apache on your webhost has mode rewrite enabled you can make use of HTACCESS to turncate long URLs into Search Engine friendly ones. Let assume that you a web domain, e.g http://www.example.com. You have URLs like http://www.example.com/topic/sub-topic.php you want to change it to a more friendly one then add .htaccess with following lines of code, in the root directory of your website. Root directory is the main folder where you FTP you web pages like
/home/yourname/http_folder/
or /local/user/http/public_html/ etc.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+).html?$ index.php?q=$1 [L

How to write .htacess file?

I know windows notepad cannot let you create a .htaccess file as it requires a file name to store its data. I have two solutions for this.

  1. Via Cpanel
    Log into your cpanel account then click on File Explorer and navigat to public_html folder. here you have to click on create new file link given on to or left panel and name it .htaccess. Then copy above given lines of code in it and save it.
  2. WinSyntax code editor
    Download winsyntax code editor (Freeware). It will allow you to save files as .htaccess on windows PC. Then you can upload it to your website with FTP utility.

Leave a Reply

Your email address will not be published. Required fields are marked *

*