Monday, March 25, 2019

htaccess tutorials

htaccess is used for many purposes here are few

  • Managing custom error pages
  • Resolving canonical issues
  • Setting up default page for a website
Here are the set of instructions to manage custom error pages


ErrorDocument 404 /404.html

ErrorDocument 401 /401.html

ErrorDocument 500 /500.html

ErrorDocument 403 /403.html

ErrorDocument 400 /400.html


404.html, is a manually created page to display custom error page when visitor tries to browse invalid file



Rewriting www website to non www website


RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^websitename\.com$ [NC]
RewriteRule ^(.*)$ http://www.websitename.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index
RewriteRule ^(.*)index$ http://www. websitename.com/$1 [R=301,L]

To set default page for website

DirectoryIndex first.html index.html index.cgi index.php


In above syntax, server initially looks for first.html if not available, looks for index.html,index.cgi and if not available, looks for index.php


No comments:

Post a Comment