Logicationz Tech

More Intelligent Solutionz…!

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.

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

Advertisements

January 3, 2010 Posted by | Helpful Tips and Tricks, htaccess | , , | 1 Comment

How to redirect www to non-www and non-www to www URL using .htaccess (mod_rewrite)

Websites can be access with www and without www also. Since Search engines consider http://www.logicationz.com and http://logicationz.com different websites, it might be a case of duplicate content. So you must stick your domain name accessible either with www or without www.

This can be done by writing only two simple lines in your .htaccess file(mod_rewrite in apache). Before writing this rules in .htaccess , make sure that your mod_rewrite is enabled(On). 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 redirect all www requests to non-www URL.

RewriteCond %{HTTP_HOST} ^www.logicationz.com$ [NC]
RewriteRule ^(.*)$ http://logicationz.com/$1 [R=301,L]

Redirect 301 means Moved Permanently so most search engines will send visitors directly to the www version of your URL.

Below is the Rules which will redirect all non-www requests to www URL.

RewriteCond %{HTTP_HOST} ^logicationz.com [nc]
RewriteRule (.*) http://www.logicationz.com/$1 [R=301,L]

Redirect 301 means Moved Permanently so most search engines will send visitors directly to the non-www version of your URL.

What you need to do is just replace logicationz with your domain name. Look at below links for more .htaccess rules.

google_protectAndRun(“ads_core.google_render_ad”, google_handleError, google_render_ad);

January 3, 2010 Posted by | htaccess | Leave a comment