.htaccess files

December 11th, 2005 by Quatrux

Using .htaccess files on your server is really useful, I found out that you can change php.ini and httpd.conf/apache.conf configuration but if the server lets to do it, well so I will show an example of my htaccess file ;)

Apache [Show Plain Code]:
  1. #######################################
  2. # APACHE CONFIGURATION FILE BEGINNING #
  3. #######################################
  4.  
  5. #****************************************************+
  6. # Enable this, but some google bots get an 406 error *
  7. #****************************************************+
  8.  
  9. #Options MultiViews
  10.  
  11. #*********************************************+
  12. # Alternative to above and googlebot is happy *
  13. #*********************************************+
  14.  
  15. #Options -Multiviews
  16. #RewriteEngine On
  17. #RewriteBase /
  18. #RewriteRule ^quatrux/(.*) /quatrux.php/$1
  19. #RewriteRule ^quatrux$ /quatrux.php
  20.  
  21. #******************************************************+
  22. # Manage Index Options                                 *
  23. #                     you can also include HEADER.html *
  24. #                             and README.html files    *
  25. #******************************************************+
  26.  
  27. #IndexOptions FancyIndexing SuppressHTMLPreamble DescriptionWidth=*
  28. #AddDescription "JPG File" *.jpg
  29. #AddDescription "GIF File" *.gif
  30.  
  31. #****************************+
  32. # Add new Extensions for PHP *
  33. #****************************+
  34.  
  35. AddType application/x-httpd-php .q .do
  36.  
  37. #*************************************************+
  38. # Default Extension for Files having no Extension *
  39. #*************************************************+
  40.  
  41.  # DefaultType application/x-httpd-php
  42.  
  43. #************************+
  44. # Default Index Settings *
  45. #************************+
  46.  
  47. DirectoryIndex index.html index.php
  48. IndexIgnore *
  49.  
  50. #******************************************************+
  51. # Change default PHP.ini Settings                      *
  52. #            Not all Options are allowed to be changed *
  53. #                             www.php.net/manual/en/   *
  54. #******************************************************+
  55.  
  56. #===========================\
  57. # ASP TAGS on/off (Boolean) +
  58. #===========================/
  59. php_flag asp_tags off
  60. #=================================\
  61. # SHORT OPEN TAG on/off (Boolean) +
  62. #=================================/
  63.  #php_flag short_open_tag off
  64. #===================================\
  65. # REGISTER GLOBALS on/off (Boolean) +
  66. #===================================/
  67. php_flag register_globals off
  68. #========================================\
  69. # SESSION USE TRANS SID on/off (Boolean) +
  70. #========================================/
  71. php_flag session.use_trans_sid off
  72. #===================================\
  73. # MAGIC QUOTES GPC on/off (Boolean) +
  74. #===================================/
  75.  #php_flag magic_quotes_gpc off
  76. #=======================================\
  77. # MAGIC QUOTES RUNTIME on/off (Boolean) +
  78. #=======================================/
  79.  #php_flag magic_quotes_runtime off
  80.  
  81. #==============================================\
  82. # MAX EXECUTION TIME time in seconds (Integer) +
  83. #==============================================/
  84. php_value max_execution_time "10"
  85. #=====================================\
  86. # ARG SEPERATOR OUTPUT value (String) +
  87. #=====================================/
  88. php_value arg_separator.output "&"
  89. #=============================\
  90. # URL REWRITER value (String) +
  91. #=============================/
  92. php_value url_rewriter.tags "frame=src"
  93. #=============================\
  94. # INCLUDE PATH value (String) +
  95. #=============================/
  96.  #php_value include_path ".:/home/user/public_html/includes/"
  97. #===========================\
  98. # USER AGENT value (String) +
  99. #===========================/
  100. php_value user_agent "Opera/8.51 (Windows NT 5.1; U; en)"
  101. #====================================\
  102. # UPLOAD MAX FILESIZE size (Integer) +
  103. #====================================/
  104. php_value upload_max_filesize 8M
  105. #==================================\
  106. # Error Reporting number (Integer) +
  107. #==================================/
  108. php_value error_reporting 2047
  109.  
  110. #******************************************************+
  111. # Error Documents Handler                              *
  112. #          Custom Error Documents are generated by PHP *
  113. #               Valid HTML META and HEADERS are Send   *
  114. #******************************************************+
  115.  
  116. ErrorDocument 400 /e.do?error=400
  117. ErrorDocument 401 /e.do?error=401
  118. ErrorDocument 402 /e.do?error=402
  119. ErrorDocument 403 /e.do?error=403
  120. ErrorDocument 404 /e.do?error=404
  121. ErrorDocument 405 /e.do?error=405
  122. ErrorDocument 406 /e.do?error=406
  123. ErrorDocument 407 /e.do?error=407
  124. ErrorDocument 408 /e.do?error=408
  125. ErrorDocument 409 /e.do?error=409
  126. ErrorDocument 410 /e.do?error=410
  127. ErrorDocument 411 /e.do?error=411
  128. ErrorDocument 412 /e.do?error=412
  129. ErrorDocument 413 /e.do?error=413
  130. ErrorDocument 414 /e.do?error=414
  131. ErrorDocument 415 /e.do?error=415
  132. ErrorDocument 416 /e.do?error=416
  133. ErrorDocument 417 /e.do?error=417
  134. ErrorDocument 500 /e.do?error=500
  135. ErrorDocument 501 /e.do?error=501
  136. ErrorDocument 502 /e.do?error=502
  137. ErrorDocument 503 /e.do?error=503
  138. ErrorDocument 504 /e.do?error=504
  139. ErrorDocument 505 /e.do?error=505
  140.  
  141. ####################################
  142. # APACHE CONFIGURATION FILE ENDING #
  143. ####################################

well and you could create your own file.php as a custom error page and do anything you like, hope this helps ;)

Posted in PHP, Webmastering | No Comments »

Leave a Comment



Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment and don't be afraid of the spam protection!