how to redirects with .htaccess ?

The .htaccess file is a small text document that generally sits in the same location as your index.php or index.htm pages. It gives you the ability to interact with Apache on an individual domain-to-domain and directory-to-directory basis.

As a configuration file, .htaccess is very powerful. Even the slightest syntax error (like a missing space) can result in your content not displaying correctly or at all.

Since .htaccess is a hidden system file, please make sure your FTP client is configured to show hidden files. This is usually an option in the program’s preferences/options

You can place the htaccess file anywhere where you’d like to control the flow of visitors. So for instance you can protect directories and redirect the traffic visiting those pages. This page will show you how to use the .htaccess file to redirect your visitors in different ways.

Redirect one page to another page

Redirect /index.html http://www.zendanwar.com/yourfoldername/index.html

Redirect index.html to a specific subfolder

Redirect /index.html http://zendanwar.com/yourfolder/

Redirect to a specific index page

DirectoryIndex index.html

301 (Permanent) Redirect

Redirect 301 / http://zendanwar.com/

302 (Temporary) Redirect

Redirect 302 / http://zendanwar.com/

How to change file extension from .php to .html

RedirectMatch 301 (.*)\.php$ http://www.zendanwar.com$1.html

Redirect www to non-www

redirect http://www.zendanwar.com to http://zendanwar.com

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.zendanwar\.com$ [NC]

RewriteRule ^(.*)$ http://zendanwar.com/$1 [L,R=301]

Redirect non-www to www

 redirect http://zendanwar.com to http://www.zendanwar.com

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.zendanwar\.com$ [NC]

RewriteRule ^(.*)$ http://www.zendanwar.com/$1 [L,R=301]