Colorado Springs Web Design Logo Design
 
  • Home
  • Logo Design
  • Web Design
  • Graphic Design
  • Personal Art
  • Contact
  • BLOG
Posted by Brent in blog on 02 10th, 2011 | one response

Here are some common .htaccess tricks to help save you some time!
(Warning: .htaccess is a very powerful configuration file. Even the slightest syntax error can result in severe malfunction to your server. You should make a back-up of everything, included any existing .htaccess files before you begin editing. It is also a good idea to check your website throughout your editing process to ensure everything is still functioning properly. If you notice an error, apply your backup immediately).

For more tips, check out “.htaccess tips part 2″ !

Enable Basic Rewriting

Not all servers have mod_rewrite (basic rewriting) enabled. You can do this by adding the following to the .htaccess file in the root directory:

# this will enable basic rewriting
RewriteEngine on


.htaccess Comments

To make a commented line, simply apply “#” before the line. This instructs the server to ignore the line.
Example:

# this line is commented out
# you must add a “#” for each line


Prevent access to a specific file

To prevent access to a particular file, use the following:

<files filenamehere.jpg>
# you can use any file extension
order allow,deny
deny from all
</files>


Prevent access to multiple file types

To prevent access to multiple file types, use the following:

<FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
Order Allow,Deny
Deny from all
</FilesMatch>


Prevent Directory Browsing

Using this will prevent the listing of all files in a particular directory. You can create an individual .htaccess file for each specific folder you wish to control:


# disable directory browsing
Options All -Indexes

Or, to enable directory browsing, use this:

# enable directory browsing
Options All +Indexes


Change the Default Index Page

If you have a page that you want your visitors to see instead of your current “index.html” or whatever it is, use this to re-define the new default page. This must exist in the ROOT directory for which you wish to replace the file.


DirectoryIndex newfilename.html
# you can use any extension


For more tips, check out “.htaccess tips part 2″ !

Article Global Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon Eli Pets

 

One Response to “.htaccess tricks part 1”

  1. .htaccess tricks Part 2 | says:
    02/12/2011 at 3:06 PM

    [...] or check out “.htaccess tips part 1″.   [...]

Leave a Reply

Click here to cancel reply.

 

Blog Categories

Social Media

Facebook:
facebook.com/brentwhitedesign
Twitter:
twitter.com/brentwdesign

Valid Feed!

[Valid RSS]



I play music too!

Listen for FREE by going to facebook.com/
brentwhitemusic/




 
 
Copyright 2004-2010 Brent White