Activity Stream
48,167 MEMBERS
6990 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1.     
    #1
    Member
    Website's:
    Doxsters.net

    Default A basic guide to htaccess

    What is .htaccess?

    .Htaccess is an incredible useful file that you can only use when using Apache(to my knowledge). It's got a tonne of functionality, which I will be detailing below. First of all, I should mention that most FTP Clients won't show you a .htaccess file because most of them are configured to hide "hidden" files, which are files with a "." in front of them. Luckily this can be changed to show all files.

    Htaccess files allow you to specify commands(kinda) which the server follows. You can of course put these commands in your httpd.conf file but most people aren't hosted on Dedicated Servers or VPS's and don't have access to it.


    Common Functions
    Error Handling
    Your .htaccess file can control what happens when the user lands on a 404 or 403, etc etc page. This is how most sites use custom error pages.
    The command is ->
    Code: 
    ErrorDocument ERRORCODE PATHTOFILE
    So say for example you had a custom 404 error page located in /404.html, your command would be:
    Code: 
    ErrorDocument 404 404.html
    Controling Access
    This is also mighty useful for securing your site. You can control who(or more specifically which IP Addresses) can access certain parts of your site.
    Okay lets say you had a few files uploaded for emergency, stored in /emergency. These files had the potential to reak havok on your site, but you had them there just incase something messed up. You didn't want anyone to access it unless something screwed up and you had to go and manually access it, this would save you reuploading the file.

    What you would do in this case is put a .htaccess file in /emergency which contains:
    Code: 
    order allow,deny
    deny from all
    This way, no-one could access it unless you deleted the htaccess, which you presumably would do in an emergency.

    But what if you wanted a certain IP Address to access that section?
    Luckily, htaccess files can do that as well.
    Heres what you would put in the htaccess file instead.
    Code: 
    order deny,allow
    deny from all
    allow from YOURIPHERE
    Htaccess files can also protect only certain files from being viewed.
    To do this, wrap your corresponding commands in <Files FILENAME>
    For example to protect Database.zip files from being viewed, you would add this to your main .htaccess
    Code: 
    <Files Database.zip>
    order deny,allow
    deny from all
    allow from YOURIPHERE
    </Files>
    To protect ALL .zip files, the code must be slightly modified. The new code would look like:
    Code: 
    <Files ~ "\.(zip)$">
    order deny,allow
    deny from all
    allow from YOURIPHERE
    </Files>
    Htaccess can also do a lot more for security and I encourage you to do some research

    Redirects
    Htaccess files can also be used for redirecting.
    The command for this is:
    Code: 
    redirect TARGETFILE REDIRECTEDTO
    For example to redirect /google.html to www.google.com, the command would be

    Code: 
    redirect /google.html http://www.google.com
    A few more tricks
    The Ifmodule tag is useful, it allows you to check whether the server has a certain module enabled.
    For example,
    Code: 
    <IfModule mod_autoindex.c>
    ADDITIONAL CODE HERE
    </ifModule>
    That code would check whether the module mode_autoindex.c is enabled, and if it is, it would execute whatever is inbetween those lines.

    You can also change the first page the server looks for with htaccess, usually index.html.
    To do this add the following to your htacecss
    Code: 
    DirectoryIndex FILE1 FILE2 FILE3
    You can specify as many files as you want, and the server will look for them in order.
    For example, with the code
    Code: 
    DirectoryIndex blah.php blahblah.php blahblahblah.php
    The server would look for blah.php first, and if that doesn't exist it would look for blahblah.php, etc

    Thats about it for this basic tutorial, I've only scratched the surface of the mighty .htaccess file and yet my fingers are dying
    I seriously encourage you to do some research into it, it is mega useful

    I might continue this later, but for now that's it.

    Oh and this was written by timtamboy63 for chrixel.com and besthostingforums.com
    timtamboy63 Reviewed by timtamboy63 on . A basic guide to htaccess What is .htaccess? .Htaccess is an incredible useful file that you can only use when using Apache(to my knowledge). It's got a tonne of functionality, which I will be detailing below. First of all, I should mention that most FTP Clients won't show you a .htaccess file because most of them are configured to hide "hidden" files, which are files with a "." in front of them. Luckily this can be changed to show all files. Htaccess files allow you to specify commands(kinda) which the server Rating: 5

    Need a Designer/Web Developer? Click Me

    MSN: PM me for it.
    Email(Preferred):timtamboy63@gmail.com

    "Power Corrupts. Absolute Power Corrupts Absolutely"

  2.   Sponsored Links

  3.     
    #2
    Retired NinJa
    Website's:
    loledhard.com
    Nice work. Truely appreciate ur work.
    .htaccess can do wonders sometime, u just need to know how to use it.

    If u use it wrong ur WEB Dir would be unavailable to u via web.



    You don't hate Justin bieber.You hate the fact you ain't Justin Bieber!

  4.     
    #3
    Banned
    Great stuff timtamboy63.

    Thank you.

  5.     
    #4
    Member
    good work, thank you

  6.     
    #5
    Member
    Website's:
    Doxsters.net
    I'll be posting more on chrixel btw, but i'll keep posting a few on here
    Oh and I just fixed a small error, its httpd.conf not http.conf

    Need a Designer/Web Developer? Click Me

    MSN: PM me for it.
    Email(Preferred):timtamboy63@gmail.com

    "Power Corrupts. Absolute Power Corrupts Absolutely"

  7.     
    #6
    mmm mmm!
    Good Tutorial
    HATERS GONNA probably bring up some valid points considering I am an ignorant little twat so far up my own ass that i blame my problems on everyone and if you criticize me you're automatically wrong.

  8.     
    #7
    Member
    great thanks. Appreciate your effort

  9.     
    #8
    Member
    noob question. i wanna rewrite mydomain.com/?c=signup displaying mydomain/signup.php, how's that using htaccess? sorry for my english.
    gomu gomu no..

    ..flying fuck!

  10.     
    #9
    Member
    Website's:
    Doxsters.net

    Need a Designer/Web Developer? Click Me

    MSN: PM me for it.
    Email(Preferred):timtamboy63@gmail.com

    "Power Corrupts. Absolute Power Corrupts Absolutely"

  11.     
    #10
    Banned
    awesom tut bud

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Guide] Warez Starter Guide For *n00bs* :D
    By CyberAff in forum Tutorials and Guides
    Replies: 19
    Last Post: 14th Nov 2012, 03:01 PM
  2. Basic Guide Line Needed to start a adult site
    By Z_UpLoAdEr in forum Webmaster Discussion
    Replies: 7
    Last Post: 17th Oct 2011, 06:18 AM
  3. [TUTORIAL] A basic guide to flipping domains for newbies.
    By Webjax in forum Tutorials and Guides
    Replies: 0
    Last Post: 20th Sep 2011, 02:42 AM
  4. what's the Basic difference?
    By kamrul in forum General Discussion
    Replies: 2
    Last Post: 31st Aug 2009, 07:28 PM
  5. Comprehensive guide to .htaccess
    By DeXTeR in forum Technical and Security Tutorials
    Replies: 2
    Last Post: 8th Nov 2008, 02:53 AM

Tags for this Thread

BE SOCIAL