Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 14 of 14

This is a discussion on .htaccess in the Shared & Semi-Dedicated forum
Could someone teach me the basics of setting up a .htaccess file? My old host didn't allow mod-rewrite, so I never got interested in persuing ...

  1. #1
    JPC Senior Member stevenha's Avatar
    Join Date
    Jul 2003
    Location
    Edmonton
    Posts
    71

    .htaccess

    Could someone teach me the basics of setting up a .htaccess file?
    My old host didn't allow mod-rewrite, so I never got interested in persuing it. But JaguarPC seems to.

    I am confused about a few things. When I use cpanel to set permanent redirects, are these stored somewhere other than a .htaccess file? ( like in httpd.conf ). If I use the cpanel feature to block hotlinking, does that go into a .htaccess file?, and if so, can I continue to edit the .htaccess file anyway, and not screw up cpanel?

  2. #2
    JPC Addict
    Join Date
    May 2003
    Location
    Canada
    Posts
    141
    Well why dont you do one of those things and then look at whats in your htaccess file? Id have to guess that chances are it does use htaccess to setup your password protected directories. Im not sure if they would store any of your personal data in the server config (httpd.conf) so again I would assume thats in the htaccess file too.

    To learn you could check out pages in the Apache manual on htaccess, but that might be a little confusing for a beginner. Try searching Google and Im sure you will turn up a bunch of results. I tend to like the tutorials/explanations at this site myself. They are thorough and pretty easy to grasp as they explain everything.
    Memento Mori

  3. #3
    Old Hillbilly Connie's Avatar
    Join Date
    Sep 2001
    Location
    Hills of Missouri
    Posts
    2,648
    I can't answer all your questions, but yes hot link protection
    will go in your .htaccess file.

    Here is what I use. This redirects the request to a 5 x 5 pix
    image. But as I understand it you could redirect to your home page
    or to another page on your web site.

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$ [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.yourdomain.com/blank.jpg [R,NC]

    If you don't want to redirect them then use this for the Rewrite Rule

    RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC] If I remember correctly this
    results in a 404 error page.

    If you place this in the root directory then all sub folder will inherit the rule.

    If you only want to protect certain folders you can put the .htaccess file in
    the folder you want to protect.

    You can continue to edit the .htaccess file without screwing up CP.
    a .htaccess file can become very large.

    Redirects are stored in the .htaccess file, but I haven't been successful
    in using them to date, but I haven't spent a lot of time trying to get
    them to work.

    After this weekend is over there will probably be more help available.
    There are a lot of very knowledgeable people here who are more than willing
    to help.

    Forum Moderators - Jag Staff

    Spam Whackers Blog - Dedicated to fighting Spam and providing General SEO Tips
    Organize your Kitchen or purchase Kitchen Accessories at Condells
    Ihelpyou Forum - Dedicated to "Best Practices" SEO

  4. #4
    Old Hillbilly Connie's Avatar
    Join Date
    Sep 2001
    Location
    Hills of Missouri
    Posts
    2,648
    Raven

    The link you provided in your post is one of the best tutorials
    I have seen on .htaccess. Thanks.

    Forum Moderators - Jag Staff

    Spam Whackers Blog - Dedicated to fighting Spam and providing General SEO Tips
    Organize your Kitchen or purchase Kitchen Accessories at Condells
    Ihelpyou Forum - Dedicated to "Best Practices" SEO

  5. #5
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Originally posted by clssam
    Raven

    The link you provided in your post is one of the best tutorials
    I have seen on .htaccess. Thanks.
    Anchors away...

    http://www.google.com/search?q=htaccess+tutorial
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  6. #6
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  7. #7
    JPC Senior Member stevenha's Avatar
    Join Date
    Jul 2003
    Location
    Edmonton
    Posts
    71
    Thanks for all of this. Some of those are good tutorials.
    And I take it then, that plopping a .htaccess file in the root directory isn't going to interfere with settings made in the cpanel.
    ( I appreciate the advice to try it and find out.. but I don't want to risk mistakes that block visitors. I read somewhere that, as far as .htaccess goes, its better to ask, than to trial&error.)

  8. #8
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Yeah, well, htaccess is a powerful tool when used right, but it can definitely screw the pooch if you don't know what you're doing. I have a 5K htaccess file in my root directory with mostly rewrites in it, and it's a godsend. It makes my Nuke site Google friendly.

    Basically, htaccess is just a text file that browsers read before doing anything, so yes, htaccess will override Cpanel 'settings', so to speak. Cpanel is just an interface to a variety of programs. Think of Cpanel as a menu system, not a program.

    If it was me, I'd use the 'lazy link' I posted above, and have it generate the htaccess code for you, do a little studying, then go back and start tweaking it.

    Baby steps, baby steps, baby steps...
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  9. #9
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775

    Re: .htaccess

    Originally posted by stevenha
    ...I am confused about a few things. When I use cpanel to set permanent redirects, are these stored somewhere other than a .htaccess file? ( like in httpd.conf )...
    Oh, yeah, I forgot to mention --- if you want to edit htaccess through Cpanel, you'll have to do it from the file manager, not the htaccess tool. You probably figured this out already though...

    I use a proggie called WinSCP2 and shell into my account. You can also use a FTP client like WS_FTP to edit htaccess files. Cpanel kinda sucks, you know? It's a crutch...
    Last edited by Vin DSL; 07-06-2003 at 05:09 PM.
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  10. #10
    JPC Senior Member stevenha's Avatar
    Join Date
    Jul 2003
    Location
    Edmonton
    Posts
    71
    Here's something I've discovered, that harkens back to my original question. Using the File Manager ( instead of WS_FTP), it showed me that a .htaccess file was present, (just invisible with WS_FTP), and it contains some Redirect statements ( which presumably were put there when I used CPanel to specify redirects).

    So, I presume then, that once I manually edit .htaccess, adding lots of mod rewrite conditions to block spiders/harvesters, then I probably shouldn't expect the CPanel's Redirect feature to usable again... so I'll be giving up that crutch/feature in CPanel. ( That is, unless someone tells me that CPanel's Redirect editor feature is really smart, well-behaved, and tested to work OK with hand-edited .htaccess files.)

    Vin DSL, thanks for the hint about WinSCP2. I'll check it out.

  11. #11
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Yes, WS_FTP hides any files that start with a "."--its a general Unix convention that any file that starts with a dot is a hidden file.

    It seems as if CPanel is smart enough not to mess up your .htaccess files when you use it to set up redirects and whatnot, but I haven't really tested it. I'm more of a do-it-yourself kind of guy when it comes to hings like this (I'm a programmer/sys admin, so it can be expected). Since you've already got some redirects set in your .htaccess, if you want to set up new ones, I'd suggest that you use the old ones as a template. If you ever get stuck, we're here to help.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  12. #12
    Kubla Khan lookout's Avatar
    Join Date
    Aug 2002
    Location
    Orodruin
    Posts
    1,386
    I prefer to edit the .htaccess file directly with a basic ASCII editor (like the Windows Notepad) myself. I've found that the cpanel stuff seems to work OK with hand-edited files. Last I looked, the cpanel tools for managing redirects and hot-linking simply added a line or two of generic code to your .htaccess file, which may or may not suit your purposes.

    Reading up on "regular expressions" would be time well invested when dealing with redirects on any serious basis. At least that should give you a clearer understanding of what's going on in with such commands.

    Since Hotlink prevention examples have been discussed here already, this thread may be of interest. It explains in greater detail what the code actually means.

    Be aware that most hotlink prevention schemes rely on evaluating the referring URL, which is not always given. Whether it is or isn't depends on the visitor's computing environment. Such measures should viewed as a means of reducing, rather than eliminating, hotlinking.
    The trouble with our times is that the future is not what it used to be.
    - Paul Valery

  13. #13
    was loyal client until...
    Join Date
    Mar 2002
    Posts
    172
    It is possible to see .htaccess with WS_FTP. On the far right, under MkDir, there is a little text box called File Mask. If you -a in there, hidden files will be displayed.

  14. #14
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    568

    Wink

    It is possible to see .htaccess with WS_FTP. On the far right, under MkDir, there is a little text box called File Mask. If you -a in there, hidden files will be displayed.
    Thanks for posting this Shwn. I've been using WS_FTP for years and I never knew this.

    I guess I should read those help files more often.
    Last edited by JonathanB; 07-07-2003 at 07:31 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •