Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: HTACCESS Resources  (Read 7718 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
HTACCESS Resources
« on: November 04, 2006, 03:51:47 pm »

What an .htaccess file is and how to use them
Stupid .htaccess Tricks
Ultimate Apache .htaccess Guide
Beginners Guide to .htaccess
Comprehensive Guide to .htacces
Using /htaccess files with Apache.
A woman's view on .htaccess
Introduction to .htaccess- The first in a 3part series that explains it well.
Online .htaccess Generator  - a fairly comprehensive .htaccess generation tool that's loaded with options and features.

Search for .htaccess files on Google for a wealth of additional information.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
HTACCESS Resources
« Reply #1 on: December 14, 2006, 05:51:19 pm »

sNews and .htaccess files - An Important Relationship

An .htaccess file is a Server Control file. They are used to customize the behaviour of the Apache Server application running in a Linux OS environment. In other words, we use these files to change the way Apache deals with the instructions served by the scripts in our web site. In the case of this file-type, the file-name and type are all-in-one... they are both one and the same. There is no other file-type like this... this is the ONLY one. This naming convention ensures that it cannot be accidentally overwritten by any other file-type, and that only one of them can exist in any directory at any time.

Rule #1: sNews uses the .htaccess file to execute certain behaviours through Apache. To do this the .htaccess file must be in your site's root directory and it must be named exactly as it is - .htaccess. And your site must be on a host server that has all the right conditions present to function properly.

In some cases, you may find that you cannot get the .htaccess file working in your site. This is not an sNews issue or bug. The problem always exists on your host's server.

Why sNews .htaccess files won't work on some servers:

Apache's mod_rewrite module is not enabled. Some hosts choose not to enable this module within their Apache server's configuration file. Their reason may be security-related, in that they don't want any of their clients creating and using .htaccess files that could cause a security breakdown on their servers. If this is the case, you have no choice but to find another host who does have this module enabled so you can use your own .htaccess files without restriction.

Apache's mod_rewrite module is enabled but your site still doesn't work. Some hosts will have this module enabled but they also put hidden .htaccess files on every client's domain root directory, and this file is 'write-protected' so that you cannot over-write it with your own .htaccess file. If you've uploaded your .htaccess file and noticed that it WAS visible on your domain's root directory right after uploading... but seemed to disappear shortly afterwards... then you have experienced this condition. A host will do this so they can have more control over security... by using .htaccess files to keep you from using them. If your host will not remove their .htaccess file from your domain root... then you have no choice but to find a better host.

Do not create Login Firewalls with CPanel. If you created a security login firewall on your domain using your domain's CPanel, that will cause the same problem. When you use this feature in your CPanel, you may not realize that it creates an .htaccess file in your root directory. It might be visible or it might be hidden. In all cases, files created this way are also write-protected so the login firewall cannot be eliminated by over-writing the file. The only way you can remove this file is by logging back into your CPanel, and de-activating it from there. Once this is done, you should be able to upload your .htaccess file.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
HTACCESS Resources
« Reply #2 on: February 11, 2007, 06:08:25 pm »

Why doesn't .htaccess work on a Microsft IIS server?
The following, from Hyper Gurlsexplains how .htaccess files work with the Apache server, and offers a solution for MS IIS servers.

Mod-rewrite is a powerful scripting program that will translate URLs based on the patterns that you define. In layman's terms, this will allow you to feed the search engines URLs that appear to be static, but are actually dynamic.

As an example, consider the dynamic URL:  http://www.yourWeb site.com/yourscript.php?id=123. This URL passes the variable called "id" to a script called yourscript.php. This script builds a dynamic page based on the product ID. How can we make this more search engine friendly?

With mod-rewrite, you can get the same result using the following URL:  http://www.yourWeb site.com/productid123.htm. Notice how the "offending" question mark symbol has been removed from the URL. This second URL is much more search engine friendly. In addition, by using the mod-rewrite technique, it will function exactly the same as the first URL.

When mod-rewrite sees "productid123.htm", it knows to translate that into "yourscript.php?id=123." This translation takes place behind the scenes, so the URL in the browser's address bar will continue to display "productid123.htm" while your database program sees the URL it is expecting to see. It is important to understand that there is no re-direction taking place. It's simply a URL translation.

Is there an alternative to .htaccess for MS IIS servers?
Yes... there is. If your Web site runs on the Microsoft IIS server, you can obtain the same basic functionality described for Apache Web sites using a program called ISAP rewrite. You can learn more about this program by visiting This Website.

Summary
Whether you're running a Microsoft or Apache server, test your changes by browsing and searching your site to see if it worked. Instead of having URLs containing question marks followed by the article or page ID, the ID should become part of the article or page name. Ampersands and commas should also be eliminated whenever possible. Hyphens, underscores, and periods should be fine.

Once you have verified that the change worked as expected, you must go into your site and change the URLs that point to each of your article or category pages so that they conform to the new format. This is critical since these are the links that the search engines will follow to find your product pages. If you leave them using the old syntax containing the troublesome symbols, then the search engines may still avoid spidering the links.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
HTACCESS Resources
« Reply #3 on: July 03, 2007, 03:35:53 pm »

If you'd like to learn more about using .htaccess to block spam-bots from using your domain bandwidth... check out The Ultimate .htaccess Blacklist.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Ken W

  • Newbie
  • *
  • Karma: 0
  • Posts: 2
HTACCESS Resources
« Reply #4 on: July 03, 2007, 08:58:38 pm »

:)
Fantastic article on HTA Access (The Ultimate .htaccess Blacklist). This is one area I have been very cautious and nervous about with not just the CMS, but with all my sites. Great job keyrocks!
Logged
"Simplicity is the ultimate sophestication..."
"quote by Leonardo da VincI"

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
HTACCESS Resources
« Reply #5 on: July 10, 2007, 10:25:09 am »

Logged
"It's only dead fish that goes with the flow... "
Updated

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: HTACCESS Resources
« Reply #6 on: June 23, 2008, 03:33:46 pm »

steerpike

  • Newbie
  • *
  • Karma: 13
  • Posts: 38
Re: HTACCESS Resources
« Reply #7 on: August 30, 2008, 06:53:47 pm »

A note on my experience with .htaccess:

For the following site: http://estatelawyerstpetersburg.com

I had not yet added the domain to my server, so I started building the site with snews on a different domain (but on the same server/computer that I would eventually add the target domain, so that they would both have access to the mysql database), and in a subfolder.

So, basically i was just building a test site in a subfolder on a different domain but on the same server.  The htaccess files were not touched and uploaded (by files I mean the .htaccess and the htaccess.txt) - (and I did not remove the #)

After uploading, I believe I did notice that the .htaccess was gone after awhile and I was left only with the .txt.

This being said.. I started building the site and everything worked fine, leaving the htaccess file as default and untouched (as I said I think it disappeared too)

OK-- then about half way thru building the site, I added the target domain to the server.

At that point I had been making any changes to index.php etc directly on the server, so I went ahead and just downloaded all the files on the server to local.. edit snews.php to reflect the new path, and then uploaded those files to the root of my newly added domain (remember same server though).. so now there is no subfolder, all the files/css folders are in root.  (since my .htaccess had disappeared on the test domain, the only htaccess that was upload to the new domain folder was the .txt htaccess)

OK-- so I log into the site on the new domain (but same server).. and great.. I see index.php just fine!.. But when I go to click on an article -- the page does not exist! (I don't even get the snews 404, but the system 404)--

So now I'm thinking... this is strange.. what the hell is going on.. it's using the same database, why can't I see the articles?  And even stranger indeed is that the articles are showing up on index.php on the sidebar thru the menu-articles function, but when I click on one, no go.  Snews MUST be able to see the database if it can show me the menu_articles function output right?  Anyway these were my thoughts..

(At this point I wasn't even thinking about htaccess BTW :)

So then I remember htaccess and I go ahead and edit the htaccess.txt - I just removed the # - and changed that line from /snews1.6 to just "/"- I save it as .htaccess, and upload it, and:

whallah! I can see the articles now and everything is working just fine on the new domain (but same server)

I then notice about a 1/2 hr later that the .htaccess disappeared, and I wonder why it's all still working even so, but don't worry about it too much, because it's.... well.. working.

In the snews readme it says that you only need to use the .htaccess if you have the installation in a subfolder, but it  was the opposite with my experience, as it worked fine on the test domain in a subfolder with an untouched htaccess, and wouldn't work on the final/target domain in the root directory without modifying the htaccess as stated above--

Anyway, I'm still a little confused by it all-- but it's still working even though maybe the server's not even using my htaccess file now that it's actually gone?

Just figured I'd share my experience just in case it might be helpful to others-- I apologize if it was a little wordy-- but that's just the way I roll..  ;D

Cheers

Logged