Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

How to remove index.php from url using .htaccess (mod_rewrite)

For better SEO optimization and make urls more search engine friendly , remove index.php from URL and make it easier to read.

Remove index.php from URL can be done by writing only two lines in your .htaccess(mod_rewrite in apache) file. Before writing this rule in .htaccess , make sure that your mod_rewrite is enabled(On) in your apache server. Most probably mod_rewrite is enabled in Linux server but for windows server , you need to contact hosting people to make mod_rewrite enabled. You can check this by looking in phpinfo().

Below is the Rules which will remove index.php from URL using .htaccess. Look at below links for .htaccess rules.

 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/ RewriteRule ^(([^/]+/)*)index\.php$ http://www.%{HTTP_HOST}/ [R=301,NS,L]

Redirect 301 means Moved Permanently so most search engines will remove index.php from URL.

To know more about programming,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.
Share:

25 Comments

  • Yes it will be helpful for SEO purpose as it will remove index.php from URL.
    It helps me as i was in search of this .htaccess rules. I found so many solutions in google but none of them works for me.
    This works for me. Thanks.

  • Yes it will be helpful for SEO purpose as it will remove index.php from URL.
    It helps me as i was in search of this .htaccess rules. I found so many solutions in google but none of them works for me.
    This works for me. Thanks.

  • Social comments and analytics for this post…

    This post was mentioned on Twitter by phpaddicted: RT: @raxit4u2: How to remove index.php from url using .htaccess (mod_rewrite) http://bit.ly/4nz3nZ

  • abril

    I was hopeful, but this code gives me a server error.
    Thanks for posting, though.

  • abril

    I was hopeful, but this code gives me a server error.
    Thanks for posting, though.

Leave a Reply

Your email address will not be published.