Let us see how do we set different types of redirection by using .htaccess file.
The following is the generic syntax to do the redirection.
The following is the generic syntax to do the redirection.
Redirect /dir1/file1.html http://abcd.com/dir2/newfile.html
1. Redirect the site from without www to with www
This is used to redirect all users who access the site without the www. prefix.For example if you want to redirect all requests which are pointing to http://abcd.com/ to http://www.abcd.com.
Add the following line to the .htaccess file
This is used to redirect all users who access the site without the www. prefix.For example if you want to redirect all requests which are pointing to http://abcd.com/ to http://www.abcd.com.
Add the following line to the .htaccess file
2. Redirect the site from with www to without www
This is used to redirect all users to access the site with the www. prefix.
This is another common requirement.For example if you want to redirect all requests which are pointing to http://www.abcd.com/ to http://abcd.com. This can be easily achieved by adding a few lines of code into the .htaccess file.Even You can make your webserver so that if someone requests http://www.abcd.com/, it does a 301 (permanent) redirect to http://abcd.com/
Add the following line to the .htaccess fileThis is used to redirect all users to access the site with the www. prefix.
This is another common requirement.For example if you want to redirect all requests which are pointing to http://www.abcd.com/ to http://abcd.com. This can be easily achieved by adding a few lines of code into the .htaccess file.Even You can make your webserver so that if someone requests http://www.abcd.com/, it does a 301 (permanent) redirect to http://abcd.com/
3. Redirect index.html to a specific sub-folder
You can redirect your default index file to a different directory or file.
Add the following line to the .htaccess file
Add the following line to the .htaccess file
4. Redirect the entire site to a different URL
Add the following line to the .htaccess file
Add the following line to the .htaccess file
5. DirectoryIndex to redirect to specific index page:
6. Redirect to secure version of your domain
This allows the users to redirect to secure site (https://)
Add the following line to the .htaccess file
This is document is found from this site: http://www.globinch.com/2010/03/25/website-or-web-page-redirection-using-a-htaccess-file/This allows the users to redirect to secure site (https://)
Add the following line to the .htaccess file
0 comments:
Post a Comment